d3d12-gpu: castable R9G9B9E5 views over R32_UINT/SINT textures without copying (D3D12-ALIAS-CAST-R9G9B9E5) #2660
Closed
github-bot
wants to merge 12 commits from
github-bot/gh-2660 into main
AGit
pull from: github-bot/gh-2660
merge into: github:main
github:main
github:perf/darner-title-priority-ceiling
github:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
github:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
github:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
github:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
github:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
github:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
github:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
github:fix/runtime-test-conservative-fixtures
github:ci/shard-semantic-linux
github:docs/fg-limit-fps-switch
github:fix/runtime-test-fixture-paths
github:fix/runtime-test-fixture-readers
github:fix/read-file-hard-link
github:fix/book-slot-heap-never-read
github:fix/depth-resolve-spv-path
github:fix/indirect-unused-batched
github:gh-pr/3358/base
github:fix/xmem-refusal-diagnostics
github:gh-pr/3357/base
github:ci/shorten-ci-time
github:fix/alias-later-queued-submissions
github:claude/gallant-sagan-aamatr
github:gh-pr/3342/base
github:gh-pr/3341/base
github:d3d12/agility-sdk-621
github:gh-pr/3293/base
github:gh-pr/3319/base
github:gh-pr/3318/base
github:gh-pr/3315/base
github:gh-pr/3313/base
github:gh-pr/3314/base
github:claude/fervent-curie-m19lnr
github:gh-pr/3216/base
github:gh-pr/3272/base
github:gh-pr/3276/base
github:gh-pr/3279/base
github:gh-pr/3257/base
github:gh-pr/3258/base
github:gh-pr/3271/base
github:codex/skip-no-hit-ray-passes
github:gh-pr/3230/base
github:gh-pr/3266/base
github:gh-pr/3247/base
github:gh-pr/3246/base
github:gh-pr/3244/base
github:claude/sharp-sagan-1jqnp3
github:t3/preserve-fsr-sdk-restart-path
github:t3/propagate-host-failure-hresult
github:t3/launcher-custom-parameters
github:t3/series-x-2160-startup
github:codex/d3d12-uncapped-simulation
github:ci/less-to-run
github:perf/native-compute-shader-forms
github:claude/blissful-franklin-ukp7ag
github:codex/full-precompile-default
github:gh-pr/3166/base
github:gh-pr/3148/base
github:gh-pr/3138/base
github:gh-pr/3106/base
github:gh-pr/3057/base
github:gh-pr/2756/base
github:gh-pr/2812/base
github:gh-pr/3032/base
github:gh-pr/2992/base
github:notes/card-time-and-plant-flicker
github:gh-pr/2986/base
github:gh-pr/3000/base
github:gh-pr/2966/base
github:gh-pr/2924/base
github:gh-pr/726/base
github:gh-pr/2761/base
github:gh-pr/2663/base
github:gh-pr/2861/base
github:gh-pr/2862/base
github:gh-pr/2820/base
github:gh-pr/2811/base
github:gh-pr/2803/base
github:rt-call-trace
github:gh-pr/2802/base
github:gh-pr/2766/base
github:perf/ahead-split
github:gh-pr/2589/base
github:gh-pr/2699/base
github:gh-pr/2696/base
github:docs/readme-runtime-proposal
github:gh-pr/1346/base
github:codex/coord-claim-check-20261124-7e48
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
area: ci
.github/ workflows and settings
area: d3d12
The D3D12 runtime in d3d12/ (Rust: leonida.exe and its crates)
area: docs
Documentation
area: launcher
The launcher (launcher/)
area: runtime (legacy)
The earlier Vulkan runtime in runtime/
area: shader translator
The shader translator (leonida-shader, tools/rdna2spirv) and its tests
area: tools
tools/ and scripts/
area: viewer
The map viewer (viewer/)
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
missing claim
Needs a claim in #14
needs in-game run
Changes the code a frame runs through: needs the 300 s in-game gate (docs/game_gate.md)
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
wontfix
This will not be worked on
No labels
accessibility
area: ci
area: d3d12
area: docs
area: launcher
area: runtime (legacy)
area: shader translator
area: tools
area: viewer
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs in-game run
needs rebase
needs-triage
question
ready-for-agent
submodules
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!2660
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2660"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@zmasi on GitHub · 2026-11-29 23:56 UTC · original
zmasi:perf/d3d12-gpu-alias-cast-r9g9b9e5→main· +2906 −116 · 5 files · 12 commits · closed without mergingClaimed in the coordination issue as: D3D12-ALIAS-CAST-R9G9B9E5 (#2570, #2570)
What and why
Eliminates the per-frame GPU copy and duplicate VRAM cost of
DXGI_FORMAT_R9G9B9E5_SHAREDEXP(67) shader views placed in the memory of shader-writtenDXGI_FORMAT_R32_UINT(42) andDXGI_FORMAT_R32_SINT(43) textures (d3d12/docs/findings.md"Aliased views of GPU-written textures:R9G9B9E5overR32_UINT" and "Open: the copies behind aliased views could go"):86reads,~390-395.6 MiB/frameacross radiance/reflection/fog targets, 4-mip probe atlases, and 6-face sky cubes) areR9G9B9E5SRVs placed over shader-writtenR32_UINTtextures because console shaders packRGB9E5manually forRWTexturestores whileD3D12_RESOURCE_DESCputsR32_UINTandR9G9B9E5_SHAREDEXPin different legacy typeless families.R9G9B9E5HostTexture(directly whenLEONIDA_ALIAS_DIRECT=1or through an intermediate staging buffer whenLEONIDA_ALIAS_DIRECT=0), costing1.6-3.6 ms/frameof GPU copy time plus duplicate texture and staging-buffer VRAM.Castable
R32_UINT/R32_SINTDefault-heap committed and placed texture creation (texture.rs,pool.rs,resource.rs):D3D12_FEATURE_D3D12_OPTIONS12(EnhancedBarriersSupported && RelaxedFormatCastingSupported) viaID3D12Device10(texture::relaxed_format_casting/texture::castable_r9g9b9e5, cached per adapter LUID without touchinghost.rs).R32_UINTandR32_SINT1D/2D/3D/array textures via bothID3D12Device10::CreateCommittedResource3(create_committed_r9g9b9e5_or_legacy) andID3D12Device10::CreatePlacedResource2(pool::texture_with_cast+create_placed_r9g9b9e5_or_legacywithID3D12Device12::GetResourceAllocationInfo3sizing/alignment) usingD3D12_BARRIER_LAYOUT_COMMON(HostTextureinitial state0 = COMMON) andpCastableFormats = &[DXGI_FORMAT_R9G9B9E5_SHAREDEXP], preserving legacyD3D12_RESOURCE_STATEStransitions (ResourceBarrier) everywhere else and falling back cleanly toCreateCommittedResource/CreatePlacedResourcewhen unavailable or refused.LEONIDA_ALIAS_CAST(default on;LEONIDA_ALIAS_CAST=0restores the copy path;LEONIDA_ABcan switchLEONIDA_ALIAS_CASTlive atPresent).Zero-copy in-place
R9G9B9E5SRV creation & stale-descriptor invalidation (descriptor/host.rs,resource.rs,draw.rs):make_twinned_infocreatesDXGI_FORMAT_R9G9B9E5_SHAREDEXPSRVs (including defaultNone/DXGI_FORMAT_UNKNOWN, 2D mip-range, 2D array,TextureCube, and 3D volume views viar9g9b9e5_srv_desc) directly on&source_copy.texture, skipping allocation ofplaced's duplicateHostTextureandThroughstaging buffer.HostTexture::serialinHostHeap::cast_serials,HostHeap::last_cast_on,ListViews::cast_serials,State::tablesfresh_tableskeys (table_r9g9b9e5_views), andStateentry_onceRecordHashkeys, plusTARGETS_CHANGED+levels_changednotifications onTARGETS_ATinsert/drop, so mid-frame or mid-list console virtual-address reuse and liveLEONIDA_ABflips invalidate cached static and dynamic SRVs immediately (and failed stale rebuilds inmake_listedoverwrites0withnull_forand returnNonewhile staying retryable).Same-pass UAV/RTV write + aliased SRV read hazard fallback (
draw.rs):WRITTEN_CAST_SOURCES(State::bindRAII guard, covering both direct andgroup.indexedentries with heap/alignment/bounds checks).source(e.g.mip m+1UAV) and samples a placedR9G9B9E5view ofsource(e.g.mip mSRV),State::tablesroutes that pass through dynamic table slots andplaced's separate copy so whole-resource legacy barriers keepsourceinUNORDERED_ACCESS/RENDER_TARGETandplacedinSHADER_RESOURCE, resuming zero-copy casting on subsequent read-only passes.Tested
--releaseD3D12 timestamp & VRAM benchmark (59views,86reads =395.6 MiB/frame,30measured frames after5warmup frames):cargo test --manifest-path d3d12/Cargo.toml --release -p leonida-gpu waterside_alias_cast_vs_copy_gpu_benchmark -- --ignored --nocapture --test-threads=1:castable-zero-copy (CAST=1):gpu_mean = 0.178 ms,gpu_median = 0.175 ms,cpu_record_median = 214.2 us,copies/frame = 0,dup_tex_vram = 0.0 MiB,stage_buf_vram = 0.0 MiB,extra_vram = 0.0 MiBcopy-direct-texture (CAST=0, DIRECT=1):gpu_mean = 1.115 ms,gpu_median = 1.063 ms(6.1xslower GPU,-0.888 ms/framemedian saved),cpu_record_median = 472.4 us(2.2xslower CPU),copies/frame = 86,extra_vram = 260.5 MiBcopy-through-buffer (CAST=0, DIRECT=0):gpu_mean = 2.417 ms,gpu_median = 2.212 ms(12.6xslower GPU,-2.037 ms/framemedian saved),cpu_record_median = 1009.8 us(4.7xslower CPU),copies/frame = 86,dup_tex_vram = 260.5 MiB,stage_buf_vram = 255.2 MiB,extra_vram = 515.7 MiB0diff lines inhost.rs):LEONIDA_D3D12_DEBUG=1 cargo test --manifest-path d3d12/Cargo.toml -p leonida-gpu --features diagnostics --lib alias -- --test-threads=4->10 passed; 0 failed; 1 ignoredwith0D3D12 debug-layer errors:committed_and_placed_r32_uint_textures_cast_to_r9g9b9e5_under_legacy_barriers(verifies bothCreateCommittedResource3andCreatePlacedResource2viapool::texture_with_cast+GetResourceAllocationInfo3and direct non-zero-offsetID3D12Heapplacement across 2D 2-mip, 2D 3-slice array, and 3D8x8x4R32_UINTtextures starting inD3D12_BARRIER_LAYOUT_COMMON, written via UAV, transitioned with legacyD3D12_RESOURCE_STATESbarriers, and sampled viaDXGI_FORMAT_R9G9B9E5_SHAREDEXPSRVs with0alias copies)make_listed_stale_rebuild_flushes_batched_copies_before_overwrite(verifiesHostHeap::make_listedflushes deferredLISTED_COPIESbefore overwritingviews.slot(at)on mid-table VA reuse)castable_r9g9b9e5_views_sample_written_r32_uint_and_sint_without_copying(2DR32_UINT&R32_SINT,DXGI_FORMAT_UNKNOWNdefault SRV, 4-mip probe atlas, 6-faceTextureCube, and 3D volume;0copies,made_copy(placed).is_none(), bit-exact match vsCAST=0)cast_alias_switches_live_and_tracks_replaced_source_at_same_addresssame_dispatch_source_uav_and_aliased_srv_falls_back_to_copy_without_state_conflictstate_tables_fresh_cache_tracks_mid_list_va_reuse_and_live_cast_flipresource::tests::*alias*(4/4),a_texture_made_where_nothing_lay_is_found_by_the_quick_way,partial_tests,pool::tests, andbook::tests(3/3) all passed.cargo clippy --manifest-path d3d12/Cargo.toml -p leonida-gpu --tests&--features diagnostics --tests, pluscargo check --manifest-path d3d12/Cargo.toml -p leonida --features diagnostics->0warnings in all new/modified code.python -I scripts/check_no_game_data.py-> clean (0issues).GPUs tested: NVIDIA GeForce RTX 3090, driver 610.88, Windows 11 Pro (26200)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)@merzleckeier on GitHub · 2026-11-30 00:14 UTC · original
Independent Wine A/B of the alias-cast tests on
fdfe5ccbf(GitHub mergedb94e6ab5). Same Win64 test binary and prefix, Wine 11.22 with VKD3D-Proton71cae091, RTX 4070 SUPER (620.73.04) and Radeon Raphael (RADV 26.3.1).d3dcompiler_47, all six tests failed in each of three runs per GPU.D3DCompilereturned successfully, thenCreateRootSignaturerejected the resulting shader blob withE_FAILattexture.rs:3848, before PSO creation.d3dcompiler_4710.0.17134.12 selected viaWINEDLLOVERRIDES, all six passed in each of three runs per GPU. That includes the live UINT/SINT views, committed and placed textures under legacy barriers, and the same-dispatch copy fallback. The ignored benchmark stayed ignored.Synthetic fixtures only. AI-assisted with OpenAI Codex.
@zmasi on GitHub · 2026-11-30 00:28 UTC · original
Thanks for running the dual-GPU Wine A/B across RTX 4070 SUPER and Radeon Raphael!
Wine's builtin
d3dcompiler_47(vkd3d-shader) drops HLSL[RootSignature(...)]attributes instead of emitting anRTS0DXBC chunk, which is why passing the shader bytecode straight toCreateRootSignaturereturnedE_FAIL. Pushedf9d9312241updatingalias_cast_tests(texture.rstest module only) to serialize each test'sD3D12_ROOT_SIGNATURE_DESCexplicitly viaD3D12SerializeRootSignature(D3D_ROOT_SIGNATURE_VERSION_1) so the suite runs without needing a natived3dcompiler_47override (10/10passing withLEONIDA_D3D12_DEBUG=1).AI-assisted.
@ItsYusei99 on GitHub · 2026-11-30 00:29 UTC · original
RUN: an in-game test on Windows, AI-assisted (Claude).
Setup:
mainat452d1d1b6plus this PR's diff (headfdfe5ccbf), applied withgit apply --3waywithout conflicts; diag profile with DLSS.Log, with
LEONIDA_ALIAS_CASTat its default:No device removed, no panic.
Picture: open sea from a boat in daylight, plus the area around a dock. The sky, clouds, sun glint, water and reflections looked normal. I saw no black or wrongly coloured patches where the radiance, fog or probe views are read. That was only a few minutes of play, and I have not yet looked at interiors or at night.
Numbers, compared with the previous build (
dd87aa405, no PR). The scenes were similar but not identical, so this is not a strict A/B:nvidia-smi)On this machine the frame is limited by the CPU: 22-28 ms a frame is spent preparing, and the GPU sits at about 73 %. So the copy time saved shows up mostly as less VRAM and GPU work, not as fps. An A/B with
LEONIDA_ALIAS_CAST=0on the same build and save would give a cleaner number. I haven't run that yet.@zmasi on GitHub · 2026-11-30 00:33 UTC · original
Awesome live telemetry —
1,512.2aliased views/frame read in place with1.0same-pass write+read hazard caught cleanly byWRITTEN_CAST_SOURCES(-500 MBVRAM on a 12 GB card,0device removals) is great confirmation. If you want a same-scene A/B without restarting,LEONIDA_ALIAS_CASTis wired intoLEONIDA_ABso it can toggle1 <-> 0live acrossPresentphases on the same camera.AI-assisted.
@merzleckeier on GitHub · 2026-11-30 00:38 UTC · original
Same-tree Wine retest of the explicit root-signature fix
8aaf91fd9onf9d931224(GitHub merge37b30335aontob8bd37111). Wine 11.22 with VKD3D-Proton71cae091, RTX 4070 SUPER (620.73.04) and Radeon Raphael (RADV 26.3.1). The loader trace confirmed Wine’s builtind3dcompiler_47in both arms on both GPUs.aliastests passed in each of three runs per GPU, including committed/placed castable textures and the same-dispatch copy fallback. The benchmark was ignored.8aaf91fd9on the same merge made all six tests fail in each of three runs per GPU. Each failed atCreateRootSignaturewithE_FAILafterD3DCompilesucceeded.The explicit serialization lets the fixture run with the builtin compiler on both adapters. Synthetic fixtures only. AI-assisted with OpenAI Codex.
@lixonik on GitHub · 2026-11-30 01:22 UTC · original
Native Windows 10 retest of
f9d93122413289069645bc9cc63bc1c4ffe98995merged locally into0eab02a8bcffbb9d1609f9c2fba40c2357513d06. Windows 10 22H2 (build 19045), RTX 5070, NVIDIA 610.88, Rust 1.98.1 MSVC, local test-executable loader exports for Agility SDK 1.614.1. Synthetic fixtures only.cargo test --locked --offline --profile diag -p leonida-gpu --features diagnostics --lib alias -- --nocapture --test-threads=1and two fresh-process reruns each reported 10 passed. The six new fixtures exercised UINT/SINT cast-versus-copy readback, live toggling and address reuse, committed and placed textures, the same-dispatch UAV conflict fallback, and descriptor re-batching.10.0.19041.7811: the adapter lacks relaxed format casting, so the six guarded casting tests returned early. The four existing alias tests passed, including the direct and staged copy cases.AI-assisted.
@lixonik on GitHub · 2026-11-30 03:31 UTC · original
Retested merge head
4a4fc668c157a967bcfaabfbc66fc5f63659da88with currentmain1d22590b9fb5c0f51a6a7c0405f1f136e0696c0dto cover the raw-twin conflict resolution indescriptor/host.rs. Windows 10 22H2 (build 19045), RTX 5070, NVIDIA 610.88, Rust 1.98.1 MSVC,--profile diag --features diagnostics, local test-executable loader exports for Agility SDK 1.614.1.LEONIDA_TWIN_BIAS=1, thealiasfilter had 10 passes anddescriptor::hosthad 53 passes. The six casting cases reached their assertions on the hardware path. The default run left the ignored microbenchmarks and descriptor probes alone.listed_off_alignment_raw_twin_readbackprobe separately withLEONIDA_RAW_VIEWS=1andLEONIDA_TWIN_BIAS=1. It stopped at the raw-twin heap prerequisite (heap.raw == 0) on both current main and main plus the PR. Coverage on this adapter includes casting, copy fallback and descriptor tests. End-to-end raw-twin readback remains unverified here.Synthetic fixtures only.
AI-assisted.
@ammonium231 on GitHub · 2026-11-30 05:59 UTC · original
RTX 3090 / 621.40, validation on,
4a4fc668cmerged onto main1d22590b9: alias tests 10 pass, 1 ignored (main 4). Release waterside bench, debug layer off, GPU median: cast 0.157 ms vs direct copy 1.125 ms (7.2x, +260.5 MiB) and copy through buffer 2.254 ms (14.4x, +515.7 MiB).@zmasi on GitHub · 2026-11-30 07:47 UTC · original
Merged into
mainviad9a75eb8f/ce8118dfb(and measured live in6d26716aa) — closing since only the post-merge sync commit4a4fc668cremained on the branch. Thanks@ItsYusei99,@merzleckeier,@lixonik, and@ammonium231for the hardware runs!AI-assisted.
Pull request closed