Repository navigation
Conversation
…castable SRVs - Create non-reserved single-sample shader-written R32_UINT/R32_SINT Default-heap textures via ID3D12Device10::CreateCommittedResource3 with [R32_UINT/SINT, R9G9B9E5_SHAREDEXP] when D3D12Options12 RelaxedFormatCastingSupported is reported (falling back cleanly to CreateCommittedResource when unavailable or refused). - Serve placed R9G9B9E5_SHAREDEXP SRVs directly on the source ID3D12Resource without allocating a duplicate placed HostTexture, Through staging buffer, or per-read CopyTextureRegion pass (LEONIDA_ALIAS_CAST, default on and LEONIDA_AB-switchable). - Track HostTexture::serial across HostHeap::mirror, HostHeap::make_listed, and texture_views_remade so console VA reuse and live LEONIDA_AB flips invalidate cached SRVs immediately. - Detect same-draw/dispatch simultaneous UAV/RTV write + aliased SRV read on the same source texture via WRITTEN_CAST_SOURCES and fall back to the separate placed copy for that pass to avoid whole-resource barrier conflicts. - Add D3D12 GPU correctness tests (2D/mip-chain/cube/3D, live toggle + VA replacement, simultaneous UAV+SRV hazard fallback) and a 59-view / 86-read waterside timestamp benchmark.
Avoids adding a field to every cached ListView entry (99%+ are non-cast views) and keeps ListView literal construction conflict-free alongside sibling descriptor-table changes.
…rebuild, and Options12 check - Hash the resolved cast_serial for placed R9G9B9E5 views in State::tables fresh_tables keys so mid-list console VA reuse and live LEONIDA_AB flips never reuse stale dynamic descriptor tables. - Overwrite stale ListViews slots with null_for and return None when a stale cast-serial rebuild fails in HostHeap::make_listed, marking cast_serials for in-place retry instead of copying stale descriptors. - Require D3D12Options12 EnhancedBarriersSupported alongside RelaxedFormatCastingSupported in Host::relaxed_format_casting. - Check group.indexed SRVs for simultaneous read+write cast conflicts, mirror shows_other cast-aliased slots in heap_textures, preserve retryability on transient mirror fallback failure, and return copy.serial when fits refuses. - Add State::tables + make_listed GPU regression test for mid-list VA reuse, mid-list cast flips, and failed stale rebuilds.
…ble views_read - Validate heap membership, non-sampler heap kind, 32-byte alignment, and checked_add + heap.index bounds before reading descriptor handles in check_cast_conflict and begin_written_cast_sources (preventing out-of-bounds dereferences on sentinel root-indexed constants such as 0xFFFF_FFFF). - Batch placed R9G9B9E5 lookup in table_r9g9b9e5_views so State::tables takes views_read at most once per table (zero times when all entries are CBVs/nulls). - Add sentinel 0xFFFF_FFFF group.indexed + out-of-bounds plan.direct regression check under active WRITTEN_CAST_SOURCES.
…edResource2 D3D12-ALIAS-CAST-R9G9B9E5 Merge origin/main and extend R32_UINT/R32_SINT -> R9G9B9E5_SHAREDEXP relaxed format casting across both ID3D12Device10::CreateCommittedResource3 and ID3D12Device10::CreatePlacedResource2 (pool::texture_with_cast + ID3D12Device12 GetResourceAllocationInfo3) using D3D12_BARRIER_LAYOUT_COMMON and &[DXGI_FORMAT_R9G9B9E5_SHAREDEXP] while keeping legacy D3D12_RESOURCE_STATES transitions everywhere and leaving host.rs untouched. Fold view_cast_serial into draw::entry_once keys and add D3D12 debug-layer GPU tests covering both committed and placed 2D, 2D-array, and 3D R32_UINT textures written via UAV and sampled in place as R9G9B9E5_SHAREDEXP. AI-assisted.
…uild D3D12-ALIAS-CAST-R9G9B9E5 - Call flush_listed() in HostHeap::make_listed before overwriting a stale views.slot(at) descriptor so deferred LISTED_COPIES (LEONIDA_BATCH_DESCRIPTORS=1) from earlier slots complete before the scratch slot is rewritten or nulled. - Check TEST_ALIAS_CAST in alias_cast_create() so alias GPU tests stay hermetic when LEONIDA_ALIAS_CAST=0 is set in the environment. - Add D3D12 debug-layer GPU test covering queued make_listed copies across mid-table VA replacement under batch_descriptors(). AI-assisted.
|
Independent Wine A/B of the alias-cast tests on
Synthetic fixtures only. AI-assisted with OpenAI Codex. |
…y for Wine D3D12-ALIAS-CAST-R9G9B9E5 Wine's builtin d3dcompiler_47 ignores HLSL [RootSignature(...)] attributes, causing CreateRootSignature from shader bytecode to fail with E_FAIL when running alias_cast_tests without native d3dcompiler_47. Remove [RootSignature(...)] from alias_cast_tests HLSL test shaders and serialize each test root signature explicitly with D3D12SerializeRootSignature (D3D_ROOT_SIGNATURE_VERSION_1) via serialize_root/compile_cs. AI-assisted.
|
Thanks for running the dual-GPU Wine A/B across RTX 4070 SUPER and Radeon Raphael! Wine's builtin AI-assisted. |
|
RUN: an in-game test on Windows, AI-assisted (Claude). Setup:
Log, with 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 (
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 |
|
Awesome live telemetry — AI-assisted. |
|
Same-tree Wine retest of the explicit root-signature fix
The explicit serialization lets the fixture run with the builtin compiler on both adapters. Synthetic fixtures only. AI-assisted with OpenAI Codex. |
|
Native Windows 10 retest of
AI-assisted. |
…cast-r9g9b9e5 # Conflicts: # d3d12/crates/leonida-gpu/src/descriptor/host.rs
|
Retested merge head
Synthetic fixtures only. AI-assisted. |
R9G9B9E5 views over R32_UINT/SINT textures the title's compute programs write are read in place through castable views (CreateCommittedResource3 / CreatePlacedResource2 with R9G9B9E5_SHAREDEXP among the castable formats, where the card reports enhanced barriers and relaxed format casting), instead of a copy through a buffer into a second texture at each read in a list (LEONIDA_ALIAS_CAST, on; 0: the copy as before; LEONIDA_AB can name it). The copies were 1.8 ms of a timing run's card time a frame here (alias, 86 commands). Merged without conflicts onto next; built, tested and measured before it goes out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… serials Conflicts in descriptor/host.rs only, where main's twin bias (1bb188c) and PR #2660's alias cast (merged into next as d9a75eb) changed the same view-making calls: make_twinned (main) is make_twinned_info (next), which also gives the cast serial. Kept both: make_twinned_info clears the twin bias first and returns (kept, cast serial); every maker takes the bias right after it (make_at, make_listed's new records with the bias in the record's stride word, the slot maker that writes the stride with the bias once the view is made) and keeps the cast serial as next did. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…aited for after a translator change - LEONIDA_ALIAS_CAST (PR #2660) by turns of 4 s standing, two runs (d156): the card -1.73 +-1.38 and -1.31 +-0.30 ms a frame, the frame's median +0.34 +-0.32 and -0.46 +-0.32 ms: the frame waits for the submitting thread here. Kept on. - After chain30's build (new translations) the pipelines not made within their 10 s wait were 10 in the second run, 55 in the third and none in the fifth and sixth; two timelines of the third run each hold a frame of about 10 s spent on one pipeline worker. Measured runs come after tours. AI-assisted (Claude). Tested on an RTX 4060 Ti 16 GB, driver 616.64, Ryzen 5 7600X. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged into AI-assisted. |
Integrates merged PR ProjectLeonida#2660 (view_cast_serial / make_twinned_info) and PR ProjectLeonida#2662 into descriptor/host.rs while preserving SLOT_ADDRESSES = 251, USER_TABLE_BASE = 0x10b, atomic 64-bit write_address, and ABA-safe release_many with zero host.rs changes. AI-assisted.
Claimed in the coordination issue as: D3D12-ALIAS-CAST-R9G9B9E5 (#2570 (comment), #2570 (comment))
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)