Skip to content

tests: verify placed attachment backing at submission (RT-PLACED-IMAGE-DEFER) - #1100

Closed
Moriz82 wants to merge 1 commit into
ProjectLeonida:mainfrom
Moriz82:split/rt-placed-image-defer
Closed

Moriz82 wants to merge 1 commit into
ProjectLeonida:mainfrom
Moriz82:split/rt-placed-image-defer

Conversation

@Moriz82

@Moriz82 Moriz82 commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Rebased onto 5129be10. #984 brought deferred slot-133 backing and the first-use fixture into main. This PR now retains three assertions from the original split. All four retry callers must succeed, an equivalent committed image must already have backing, and closing the command list must leave allocation deferred until submission in the default mode. The original test report is below. On c92dc976, d3d12_existing_heap passed 1/1 with deferred backing and 1/1 with LEONIDA_PLACED_IMAGE_DEFER=0 under Wine 11.22 on an RTX 4070 (NVIDIA 620.73.04). Both runs cover the four retry callers, the committed control, the backing check after close, and the 128-pixel readback.

Claimed in the coordination issue as: RT-PLACED-IMAGE-DEFER (claim).

Part of the split of #984 into small pull requests.

Depends on: none

Overlaps: #1079 resolves shader views of live placements by address. This change uses the existing slot-133 placement path on main. Streamed sources and shared BC backing are tracked separately.

What and why

Slot 133 allocated private Vulkan memory for every placed render target, depth/stencil target and storage texture, including attachments that only received a logical descriptor. On a device with a limited memory budget, unused attachments compete with active ones.

The image and its format and layout metadata still exist at creation. The runtime binds memory on the first command replay, shader view or CPU subresource copy that needs the image. Concurrent callers share one successful bind. A failed allocation or bind can be retried, and a failed bind releases its unused allocation. Set LEONIDA_PLACED_IMAGE_DEFER=0 for eager allocation.

Tested

Release cross-build with clang-cl 23 and an xwin SDK. Commands use a configured build directory. PROTON_WINE names the Wine executable and WINEPREFIX selects the test prefix.

cmake --build runtime/build/boot --target gta6rt -j6
cmake --build runtime/build/boot --target d3d12_existing_heap_test -j6
cd runtime/build/boot
export WINEDEBUG=-all
unset LEONIDA_PLACED_IMAGE_DEFER
timeout 120 "$PROTON_WINE" d3d12_existing_heap_test.exe
LEONIDA_PLACED_IMAGE_DEFER=0 timeout 120 "$PROTON_WINE" d3d12_existing_heap_test.exe

Both targets built. The existing-heap test passed twice on the same binary. Each run used a 16 × 8 RGBA8 render target placed at a reserved, inaccessible address.

Check Default Eager rollback
Placed target has backing after RTV creation and command-list close No Yes
Equivalent committed target has backing at creation Yes Yes
Placed target has backing after clear and copy Yes Yes
Cleared pixels read back as magenta 128/128 128/128
Bind helper after one injected failure 4/4 callers succeeded, one successful bind 4/4 callers succeeded, one successful bind

GPUs tested: NVIDIA GeForce RTX 4070 12 GB, driver 620.73.04, CachyOS kernel 7.3.5, Proton Experimental (Wine 11). Native Windows, AMD, Intel and a game boot were not tested on this child. The optional XMA decoder was omitted from the cross-build because its Rust target was unavailable.

AI-assisted: yes.

Checklist

  • One commit directly on upstream main 3aa975421.
  • One runtime change with synthetic render-target readback and a rollback control.
  • All tracked files passed python3 -I scripts/check_no_game_data.py.
  • Runtime only. No translator contract changes.

🤖 Generated with Claude Code

@Plaaasma

Copy link
Copy Markdown
Contributor

Native Windows check, AI-assisted (Claude Code). Windows 11, i9-13900K, 64 GB, RTX 4070 Ti 12 GB (NVIDIA 630.20), MSVC 2022 (VS 17 generator, Release), Vulkan.

Head 84d0675f1. Built d3d12_existing_heap_test, then ctest -C Release -R "^d3d12_existing_heap$" --output-on-failure --timeout 300:

  • d3d12_existing_heap: passed, 1.17 s (exit 0)
  • new case: first GPU use: deferred backing, 128 cleared pixels matched; four first-use callers, two bind attempts
  • OpenExistingHeapFromAddress: 8 cases match against both the host NVIDIA adapter and WARP

1 passed, 0 failed.

@abnalstlll-byte abnalstlll-byte 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.

Audited and verified. Implements lazy memory binding (DeferredImageBinding) for title-placed GPU-only attachment textures in slot 133, deferring physical allocation to first replay or view use while allowing RTV/DSV creation immediately from metadata. Thread-safe single-initialization with retry semantics. Tests in
untime/test/d3d12_title_placed_test.cpp verify execution and clearance. Approved.

@abnalstlll-byte abnalstlll-byte 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.

Clean-Room Audit — PR #1100 (RT-PLACED-IMAGE-DEFER)

Clean deferred memory binding design for placed render target / depth-stencil / UAV textures (DeferredImageBinding) until first use, preventing premature allocation failure while keeping LEONIDA_PLACED_IMAGE_DEFER=0 override and full readback pixel verification in d3d12_existing_heap_test.cpp. 0 game data.

Verdict: APPROVED

@iFeyz

iFeyz commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

AMD run (the gap the description lists): RX 9070 XT (RDNA4, GFX1201), AMD proprietary Windows driver 26.11.2 (LLPC, Vulkan 1.4.359), Windows 11, MSVC 2022 RelWithDebInfo.

Head 84d0675f1: d3d12_existing_heap built from it passes on this AMD machine (MalexAson reported this test failing on an Intel Iris Xe in #14, so it is not a general Windows failure).

@Deedlyy

Deedlyy commented Nov 24, 2026

Copy link
Copy Markdown

Recommendation: [MERGE]

Reasoning: Slot-133 placed render-target/DS/storage images now bind memory on first GPU use instead of always allocating private memory, which cuts memory pressure on limited-budget devices. A moderate runtime behaviour change (+194, new deferred_image_binding.h) with a 102-line test. Verified on NVIDIA RTX 4070 Ti and AMD RX 9070 XT. Watch for interaction with #1079 and with #1190/#1192, which touch the existing-heap test. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with main. Merge once the queued checks are green.

Impact level: 6/10

@whoalin1

Copy link
Copy Markdown
Contributor

GPU verification (AI-assisted, overnight worker w4; independent run, not the author's).

Head tested: 84d0675 on this machine's two GPUs.

AMD Radeon iGPU (gfx1035, RDNA2, driver 24.10.24, Vulkan 1.3.280) — env: VK_LOADER_DRIVERS_SELECT=*amd-vulkan* LEONIDA_VK_DEVICE=radeon VK_LOADER_LAYERS_DISABLE=~implicit~ LEONIDA_VK_VALIDATION=1 LEONIDA_PC_TAIL_UBO=1

NVIDIA RTX 4070 SUPER — env: VK_LOADER_DRIVERS_SELECT=*nv-vk* LEONIDA_VK_DEVICE=4070 VK_LOADER_LAYERS_DISABLE=~implicit~

  • ctest -R "d3d12|vk_" -j4: 141/142 passed; only d3d12_execute_indirect_validation fails — same 5 parity failures reproduce on unmodified main (verified), pre-existing.
  • The 4 placed-image tests also pass on NVIDIA.
  • run_gpu_tests.py: 203/252 passed, 49 skipped, 0 failed.

Verdict: deferred placed-image binding shows no regressions on either GPU; the new concurrency/retry coverage passes under validation. LGTM from this hardware.

clquwu pushed a commit to clquwu/leonida-ultimate that referenced this pull request Nov 25, 2026
…984 LAYOUT_UNDEFINED, Wave-21b CMake & leonida-ce 525c44e1 ReadFile fast-path

- ProjectLeonida/mandy#1100 (RT-PLACED-IMAGE-DEFER): unify Resource deferred memory binding onto leonida::DeferredImageBinding (deduping duplicate flags/mutex), add LEONIDA_PLACED_IMAGE_DEFER=0 rollback, defer placed depth/UAV/RT attachments + cpu_copy bind + race-free memory_flags(), preserve MemoryPriority, add check_placed_target_backing test & docs/d3d12_vulkan.md note.
- ProjectLeonida/mandy#1099 (RT-STREAM-TRANSFER-BARRIER): deduped against existing ultimate CopyBuffer/CopyResource transfer barriers; add LEONIDA_ORDER_BUFFER_COPIES=0 opt-out toggle, --expect-unordered test mode, and docs/d3d12_vulkan.md note.
- ProjectLeonida/mandy#1097 (SHADER-BUFFER-BOUNDS): use OobSelect::structured_with_offset for structured buffer SRVs in d3d12_vulkan_device.cpp, add cross-record GPU readbacks in d3d12_compute_test.cpp + cs_user_data.comp (and align Xbox slot-17 CBV expectations with wave18b vector-row encoding).
- ProjectLeonida/mandy#1096 (RT-STARTUP-TRACE): add VirtualQuery memory region metadata on access violations in startup_trace.h & startup_trace_test.cpp.
- ProjectLeonida/mandy#1023 & #1007: update docs/directstorage.md (measured factory IID & slot 8) and docs/d3d12_vulkan.md (device slot 62 5-arg arity & slot 76 FFX-only note).
- Wave-21b deferred CMake: add loader TIMEOUT 180 (Reforge#169) and tiny_game_ga / run_tiny_game_ga_tls (ubiq#947 Patch 2).
- ProjectLeonida/mandy#984 (self-contained Windows-native port): accept enhanced TextureBarrier into LAYOUT_UNDEFINED without violating VUID-VkImageMemoryBarrier2-newLayout-01198 (command_list.h, vulkan_replay.h, command_list_test, replay_texture_barrier_test, d3d12_close_parity_test).
- IAmNotSiob/leonida-ce 525c44e1 (GPL-3.0, deduped): wire optional xmem::commit_physical_range_fn hook into file_system.cpp ReadFile ERROR_NOACCESS retry path to commit large console buffers without per-page VEH faults while keeping zero-cost fast path and touch_pages fallback.
- DesignWithTommy/Neonbridge eaf7e7e0: audited and skipped (ultimate has no refresh read-back byte/time cap skipping Bink R8/R8G8 planes).
@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 25, 2026
@Moriz82

Moriz82 commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

The deferred slot-133 backing and the matching first-use test are on current main via #984. The test exercises a failed bind and retry, four concurrent callers, and the readback of 128 cleared pixels. The older split also conflicts with the newer image-pooling and placement code, so a rebase would reintroduce overlapping runtime paths.

AI-assisted.

…E-DEFER)

Retain the regression checks omitted from the integrated fixture. Verify
the four retry callers each succeeded, an equivalent committed image
already has backing, and closing the command list leaves the placement
in its expected state until submission.

Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@Moriz82
Moriz82 force-pushed the split/rt-placed-image-defer branch from 84d0675 to c92dc97 Compare November 25, 2026 03:55
@Moriz82 Moriz82 changed the title d3d12: bind placed GPU attachments on first use (RT-PLACED-IMAGE-DEFER) tests: verify placed attachment backing at submission (RT-PLACED-IMAGE-DEFER) Nov 25, 2026
@Moriz82

Moriz82 commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator Author

I checked the old runs on 84d0675. CI, No Game Data, and Runtime were waiting for maintainer approval. The conflict-label job was cancelled before it reached a runner.

I rebased the remaining regression assertions onto 5129be10 and pushed c92dc976. The implementation is already in #984. This diff checks all four retry results, the committed-image control, and the placement’s backing after command-list close. On c92dc976, d3d12_existing_heap passed 1/1 with deferred backing and 1/1 with LEONIDA_PLACED_IMAGE_DEFER=0 under Wine 11.22 on an RTX 4070 (NVIDIA 620.73.04). Both runs cover the four retry callers, the committed control, the backing check after close, and the 128-pixel readback.

AI-assisted.

@Gefik23

Gefik23 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Tested 84d0675 on NVIDIA GeForce RTX 4060 (Ada), driver 617.42, Windows 11 Pro build 26200, native Windows (not Proton): pass.

Built at this head with scripts\build_runtime.ps1 (MSVC 19.44, VS 2022 Build Tools, Ninja, RelWithDebInfo, Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0).

AI-assisted (Claude Code ran the build and tests). No game files.

@Moriz82

Moriz82 commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

@Gefik23 Thanks for the native Windows run on 84d0675f1 and for checking the d3d12_execute_indirect_validation failure against main. #1066 is already in the current head.

Could you rerun the targeted test on c92dc9762, once with LEONIDA_PLACED_IMAGE_DEFER unset and once set to 0? Both passed under Wine 11.22 on this head.

ctest --test-dir <build> -C RelWithDebInfo -R "^d3d12_existing_heap$" --output-on-failure

AI-assisted.

@github-actions github-actions Bot removed the needs rebase Conflicts with the base branch: rebase it on main label Nov 25, 2026
@Moriz82 Moriz82 closed this by deleting the head repository Nov 26, 2026
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.

7 participants