Skip to content

Runtime: map sparse reserved RGBA8 texture tiles (D3D-285) - #2382

Draft
gabrielsteglich wants to merge 914 commits into
ItsNotRexed:mainfrom
gabrielsteglich:feat/reserved-texture-tile-mapping
Draft

gabrielsteglich wants to merge 914 commits into
ItsNotRexed:mainfrom
gabrielsteglich:feat/reserved-texture-tile-mapping

Conversation

@gabrielsteglich

Copy link
Copy Markdown
Contributor

Claimed as D3D-285 in #313. Builds on the reserved-buffer tile mappings merged in #987.

What and why

Extend the D3D12-to-Vulkan runtime's sparse tile mappings to compatible reserved 2D textures. UpdateTileMappings, CopyTileMappings, and CopyTiles reuse the sparse queue synchronization from #987. CopyTiles uses a transfer buffer when a byte offset does not meet Vulkan's texel-block alignment requirement.

Scope

The sparse image path supports R8G8B8A8_UNORM 2D textures with one mip, one array layer, one sample, and no resource flags. It requires a compatible Vulkan sparse image with 128 × 128 color blocks, 64 KiB tile alignment, sparse aliasing, and zero reads from unmapped tiles. Unsupported texture descriptions use fully allocated backing. Sparse image heaps are separate from buffer and placed-resource heaps. This draft provides synthetic coverage while the game's use of sparse texture streaming remains open.

Tested

Commit f8e89767f66de8f2a375615ca96a10459a87fef7 on base 49475796. Windows 11 build 26300, NVIDIA GeForce RTX 3090 (driver 621.01), MSVC 19.44.35229, Windows SDK 10.0.28000, Vulkan SDK 1.4.363.0, RelWithDebInfo with Vulkan validation enabled.

  • Full runtime CTest suite had 111 passing tests, 6 skipped, 1 disabled, and 0 failures.
  • d3d12_buffer_tiles and d3d12_texture_tiles each passed 10 consecutive runs.
  • Direct Vulkan replay matched native D3D12 across all 730,624 checked pixels with zero Vulkan validation errors. The synthetic cases cover unmapped reads, tile aliasing, fence-gated remapping, clipped edge tiles, and byte offsets 4, 1, and 3.

Checklist

  • No game data, keys, or decryption in the change or test results.

AI-assisted (OpenAI Codex).

@Flyander Flyander 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.

The sparse RGBA8 tile path respects the reserved resource requirements, validates the mapping bounds and resource pairing, and records the required copy/graphics ordering before deferred release. The buffer-to-texture restriction is explicit in the supported scope. I found no further static issue.

@kapitche

Copy link
Copy Markdown
Contributor

Tested on Windows 11 with two GPUs on one machine (MSVC 14.51, llvm-mc 23.1.6): pass. ctest: 125/125 on the RTX 4080 SUPER. On the Intel UHD 770 only the known d3d12_descriptor, d3d12_present and d3d12_subgroup fail (#2516).

@umnitus

umnitus commented Nov 22, 2026

Copy link
Copy Markdown

Independent check at f8e8976 on Windows 11, RTX 3060 12 GB, driver 621.14. d3d12_buffer_tiles_test and d3d12_texture_tiles_test both exited 0. The buffer test matched all three native D3D12 readbacks. The texture test matched all 730,624 pixels across offsets 4, 1 and 3, including unmapped reads, aliasing and fence-gated remapping. Vulkan validation was off.

AI-assisted testing and write-up.

@gabrielsteglich

Copy link
Copy Markdown
Contributor Author

Could a maintainer confirm whether Leonida already has a trace showing the game using reserved texture tiles for streaming? If no trace is available yet, would you be comfortable reviewing this limited implementation on its synthetic coverage? I kept the PR in draft because the runtime design notes call for evidence of streaming use. A summary of the calls and resource types would be enough for this discussion.

I resolved the merge conflicts and retested 90f10662 with main at f847748c on an RTX 3090 (driver 621.01, Vulkan validation enabled). The runtime suite had 127 passes, 7 skips, 1 disabled test, and 0 failures. The buffer and texture tile tests each passed ten consecutive runs. The texture replay matched native D3D12 across all 730,624 checked pixels with zero validation errors. The supported scope is single-mip, single-layer RGBA8 2D textures.

AI-assisted testing and write-up.

ItsNotRexed and others added 21 commits November 22, 2026 17:03
# Conflicts:
#	docs/design.md
# Conflicts:
#	runtime/README.md
- design.md: escape the literal pipes that split contract-table rows again, and merge the 76 repeated topics into
  one row each (sentence by sentence; no number dropped).
- d3d12_vulkan.md: one milestone row per ID (the most complete of each), and LEONIDA_ARENA_LOG documented with the
  arena high-water report (D3D-55).
- navmesh.md: one item 4 and 5 under Remaining unknowns (the +0xB8 footprint and octree-key wording).
- sandbox.md: name vk_sandbox's source file; i18n index: one pt-BR row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- replay_cpu_bench: ItsNotRexed#3693 moved a draw's render targets and vertex buffers into Draw::views (D3D-391); the bench
  builds a DrawViews block instead of writing the old inline arrays.
- xgameruntime_user_test links file_system.cpp, which now defines rt::fs::game_dir that xgameruntime.cpp calls.
- check_sparse_queue_family: a vkCreateInstance refused because the api_dump/validation layer is not installed is
  the documented "layer absent" skip (77), not a failure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This reverts commit 718f105, reversing
changes made to 9aa16b2.
ItsNotRexed and others added 7 commits November 22, 2026 21:10
- test_bary_fallback: ItsNotRexed#3647 (BUILD-1046) made a missing input folder exit 2 with "does not exist"; the test from
  ItsNotRexed#1379 still expected exit 1.
- test_format_decode_branch: the f16 reference uses the interpreter's pinned half_to_float (a NaN half widens to
  the canonical quiet NaN) instead of struct's '<e', whose NaN payload changed in Python 3.14 (CPython gh-130317).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merges that each passed alone but clash together:
- v_cmp_class_f64: the earlier cmp_class_f64 (685d16e) (operand-form checks, test_cmp_class_f64) and the later f64 branch
  in cmp_class both handled the opcode; f64 goes to cmp_class_f64 again, f16 stays in cmp_class.
- rdna2spirv CLI tests: spirv-as/spirv-val now run in the output folder with the staging file's bare name, so
  the test doubles resolve it against cwd; assemble_spirv decodes the output only when it is bytes. (The doubles
  had been writing .spirv-*.tmp files into the repository root.)
- ps_w64 fixtures (TEST-722): an 18th fixture (ps_w64_a_discard) landed; its killed lanes export nothing and
  keep the clear value.
- first_light: a run without an OBJ removes mesh.bin, and harness_env reads manifest["files"]; batch_glb's stats
  name failures and dropped textures; run_gpu_tests reports a frame never written as a missing readback
  (TEST-837).
- make_game TRANSLATION_SOURCES and runtime.yml's paths include spirv_opt.py and report_paths.py (and
  wave64_emulate_opt.py), which the translator imports.
Repo rules: stdout guard on six tools; encoding on two opens (gen_gdk_runtime_classes' helper is read_utf8);
newline on one write; anim_skeleton_match's joaat encodes like hashdict.joaat; test_feature_scan's new test is
listed with the others its globals() runner reaches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This reverts commit ce318cd, reversing
changes made to a78f170.
# Conflicts:
#	docs/runtime_imports.md
#	runtime/CMakeLists.txt
#	runtime/shims/xgameruntime.cpp
#	runtime/test/xmem_test.cpp
#	tools/rdna2spirv.py
- rdna2spirv: %fmt_size_tab (main's typed-load size table) registers its length and entry constants when a load
  first uses it; created at assembly, %c128 came after the OpTypeArray naming it and spirv-val refused
  buffer_store_format_d16 modules (test_u16_high_half).
- test_vs_packed_inputs matches main's wording of the same SHADER-644 rule ("mixed component types").
- test_mutations: the v_mul_legacy_f32 anchor follows the SHADER-340 flushes (it had stopped matching on main).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ItsNotRexed#2887 added the fixture to the M2 build; with no entry in OTHER_HARNESS the GPU suite reported it as
"no checker defined".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

5 participants