D3D12.X: encode T# MIN_LOD, resolve wildcard SRV/3D-UAV counts, and validate CreateUnorderedAccessViewAt #3258
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3258"
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?
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T01:37:46Z.
Fix three D3D12.X texture view descriptor bugs in
real.rs: encode SRVResourceMinLODClampinto RDNA2T#MIN_LOD(t[1][19:8]), resolve wildcardArraySize/NumCubes/ 3D UAVWSize(u32::MAX) counts safely, and routeCreateUnorderedAccessViewAt(#71) throughdev_create_uav_checked_inner.Previously:
srv_tsharp_from_descleftT#MIN_LOD(t[1][19:8], u4.8 fixed-point) at0for all SRV dimensions, so direct-DXIL explicit-LODimage_gather4_l/image_gather4_c_l(which clamp againsttw1[19:8]) ignoredResourceMinLODClamp.srv_tsharp_from_descpassed rawArraySize == u32::MAXthrough intoT#depth (0x1FFE) and evaluatedNumCubes.max(1) * 6without saturation/resolution (overflowing whenNumCubes == u32::MAX), whiledev_create_uav_xignoredTexture3DUAVWSizeand shifted the full resource depth instead of resolvingWSize/u32::MAXfromFirstWSlice.dev_create_uav_at_xcalleddev_create_uav_xdirectly, bypassingdev_create_uav_checked_inner's sRGB-to-linear format mapping andTYPED_UNORDERED_ACCESS_VIEWcapability fallback.What is in it
crates/xcl/src/hle/d3d12x/real.rs:encode_tsharp_min_lodand populatet[1][19:8]fromResourceMinLODClampacross all 7 SRV view dimensions that carry it (1D,1DArray,2D,2DArray,3D,Cube,CubeArray).ArraySize(0/u32::MAX) on1DArray/2DArray/2DMSArraySRVs andNumCubes(0/u32::MAX) onCubeArraySRVs against remaining slices/cubes usingresolve_uav_array_size.Texture3DUAVWSize(0/u32::MAXand explicit sub-ranges) against((rd.DepthOrArraySize >> mip).max(1))andFirstWSliceindev_create_uav_x.dev_create_uav_at_xtexture views throughdev_create_uav_checked_inner.srv_tsharp_encodes_min_lod_and_resolves_wildcard_array_and_cube_counts, WARP child-process testuav_3d_tsharp_wsize_and_uav_at_checked_format, and guarded RTX GPU testgpu_srv_tsharp_min_lod_clamp_controls_image_gather4_l_mip.Tested
rustc 1.99.0 (b940084d7 2026-09-28), DXC 1.9 (XCL_DXC_DIR), debug for tests and release forxcl-smoke.cargo test -p xcl --lib -- srv_tsharp uav_3d_tsharp_wsize_and_uav_at_checked_format uav_companion_srv gpu_a_stencil_uav_by_address_is_a_view_of_the_placed_buffers_twin --nocapture): all 3 new tests failed before the fix; 8 passed, 0 failed after (0 skips on RTX 5070 Ti; verifiedIMAGE_GATHER4_LhonorsResourceMinLODClamp=1.0-> mip 10.75vs0.0-> mip 00.25, 3D UAVWSize=3andWSize=u32::MAXat mip 1, anddev_create_uav_at_xsRGB linearization on WARP).cargo test --workspace -- --test-threads=4 --skip test_title_runs_and_game_folder_is_untouched --skip uma_driver::tests::): 2602 passed, 0 failed, 49 ignored.SKIPPEDGPU tests on this wave32 adapter (26 total across--nocaptureworkspace baseline): 21no wave64(RTX 5070 Ti is wave32), 3 wave32 per-lane#1426f16/cvt-f16 refusals, 2no heap windows(opt-inXCL_HEAP_WINDOWS=1).ea3b5e4d) 150 s regression run below (0device removals,0crashes,1918frames vs1695onmain,31029 MBpeak commit vs31546 MBonmain).Regression run
Not tested
ResourceMinLODClampor sub-range 3D UAVWSize(ea3b5e4dsmoke is a regression check; behavior is verified by the unit, WARP, and RTX GPU tests).uma_driver::tests::(skipped locally due to pre-existing0x7C10003exit on NVIDIA) andtest_title_runs_and_game_folder_is_untouched.AI use
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:35:17Z.
merge-check
base:
d0832e614fhead:
987c02536fmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2893 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (real.rs, +477/-19, ~420 lines of tests). Three default-path changes: every SRV with
ResourceMinLODClamp > 0now carries T# MIN_LOD; 3D UAV T# depth is the resolved WSize and wildcard array / cube counts are resolved; and texture UAVs created by address now get sRGB -> linear and a null view for formats the PC can't use as typed UAVs. Findings: (1) three unrelated fixes in one PR, 477 lines; CONTRIBUTING asks for one per PR. (2) On main only thegather4_llowering reads MIN_LOD (lower_image.rs ~546-555), comparing the raw clamp with a LOD counted from the view's first mip, while I believe D3D12's ResourceMinLODClamp counts from the resource's mip 0; every test uses MostDetailedMip = 0, so a case with MostDetailedMip > 0 would settle it. (3) No translated shader reads T# depth (get_resinfouses GetDimensions on the PC view), so the array / cube / 3D-UAV depth changes only affect the T# words; theNumCubes * 6overflow fix stands (a debug-build panic inside an extern "system" function on main). (4) AI use says "Antigravity (Gemini)", not an exact model; the PR's suite run skippedtest_title_runs_and_game_folder_is_untouchedanduma_driver::tests::(stated). Fine: MIN_LOD sits in t[1][19:8] as u4.8, matching thedesc::imagedecode, and NaN / negative / >= 16 clamps saturate correctly; the by-address UAV path now gets the same sRGB mapping and typed-UAV null fallback as CreateUnorderedAccessView, and the calls it changes were invalid PC calls on main; each new test fails without its fix.performance: 60 s smoke of a retail title, main
d0832e61vs this merge (0ecc628e): 1516 -> 1677 frames shown (110 %; last presents per 2 s: 60 60 60), peak commit 18133 -> 17167 MB, 0 device removals, 0 crashes.verdict: not yet: three unrelated fixes in one 477-line PR should be split, and MIN_LOD with MostDetailedMip > 0 is untested against D3D12's clamp convention
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
AI-written and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T20:50:06Z.
Closing: split per @Foniass's review. The
T# MIN_LODencoding part is consolidated into #3730 with unit and hardware D3D12SampleLevelparity coverage forMostDetailedMip > 0(max(0, clamp - MostDetailedMip)); the unrelated wildcard SRV/3D-UAV count andCreateUnorderedAccessViewAtchanges were dropped.Pull request closed