D3D-CLEAR-UAV-3D-SLICE: clear selected 3D UAV slices and rectangles #1814

Merged
timbot103 merged 1 commit from upstream-pr/1814 into main 2026-11-25 19:29:09 +00:00
timbot103 commented 2026-11-25 12:27:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-25T12:27:23Z.


Claimed in the coordination issue as: D3D-CLEAR-UAV-3D-SLICE

What and why

ClearUnorderedAccessViewUint and ClearUnorderedAccessViewFloat can now clear selected W slices of a 3D texture mip and apply XY rectangles to each selected slice. A tagged descriptor carries the W range through a descriptor copy. An untagged descriptor uses the bound resource's mip depth, and an unpredicated whole-mip clear uses the existing fast path.

The staged path fills up to 64 KiB of scratch once and reuses the pattern across tiles and slices. It supports direct and compute queues, clips rectangles to the mip, and orders overlapping writes. It refuses predicated staged clears and incompatible 3D view/backing formats. The existing packed RGB9E5 representation on R32_UINT is supported.

Tested

  • Built all 11 UAV/clear/replay test binaries and linked gta6rt with MSVC 2022, Ninja and RelWithDebInfo. A clean build matched the warning set on unmodified 0d80bc5df.
  • Ran 14 invocations on each GPU with Khronos validation and synchronization validation enabled and disabled. Across the four configurations, 52 invocations passed, two skipped and two failed. There were zero Vulkan validation errors.
  • Native D3D12 WARP and Vulkan produced identical Uint and Float readbacks for partial W clears and rectangles at mip 1. The comparison covered every texel on direct and dedicated compute queues, including the adjacent slices and mip. The full texture UAV test also passed 14 GPU cases, 10 compared with WARP, on both GPUs.
  • Both GPUs accepted a predicate on direct and compute lists using the graphics family, then refused a predicated staged clear. On the dedicated compute families the existing backend refused predicate capture before clear replay.
  • Regression controls caught both undersized and oversized untagged descriptor depths. Omitting the mip-1 RGB9E5 Uint write left 48 incorrect bytes in the seeded slice.
  • The RTX 5080 skipped the native RGB9E5 render-target probe in both modes. Radeon failed the existing default D32 NaN depth-clear test in both modes (15 texels read 1, WARP expected NaN). Both outcomes reproduced on unmodified 0d80bc5df. The 3D UAV clear tests passed in all four configurations.

GPUs tested: NVIDIA GeForce RTX 5080, driver 616.64, Vulkan 1.4.351; AMD Radeon(TM) Graphics, driver 25.10.30.02 (Windows 32.0.21030.2001), Vulkan 1.4.315. Both on Windows 11 Pro build 26200.

AI-assisted: yes (Gemini, Codex, Claude)

Checklist

  • Based on current main at 0d80bc5df.
  • One topic, 3D UAV clear ranges and rectangles.
  • No game data, keys or decryption. The repository content check passed for every changed file.
  • Translator contract table — not applicable to this runtime-only change.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5491308900 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1814). Originally posted by [timbot103](https://github.com/timbot103) on 2026-11-25T12:27:23Z. --- Claimed in the coordination issue as: [D3D-CLEAR-UAV-3D-SLICE](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7161533493) ### What and why `ClearUnorderedAccessViewUint` and `ClearUnorderedAccessViewFloat` can now clear selected W slices of a 3D texture mip and apply XY rectangles to each selected slice. A tagged descriptor carries the W range through a descriptor copy. An untagged descriptor uses the bound resource's mip depth, and an unpredicated whole-mip clear uses the existing fast path. The staged path fills up to 64 KiB of scratch once and reuses the pattern across tiles and slices. It supports direct and compute queues, clips rectangles to the mip, and orders overlapping writes. It refuses predicated staged clears and incompatible 3D view/backing formats. The existing packed RGB9E5 representation on R32_UINT is supported. ### Tested - Built all 11 UAV/clear/replay test binaries and linked `gta6rt` with MSVC 2022, Ninja and `RelWithDebInfo`. A clean build matched the warning set on unmodified `0d80bc5df`. - Ran 14 invocations on each GPU with Khronos validation and synchronization validation enabled and disabled. Across the four configurations, 52 invocations passed, two skipped and two failed. There were zero Vulkan validation errors. - Native D3D12 WARP and Vulkan produced identical Uint and Float readbacks for partial W clears and rectangles at mip 1. The comparison covered every texel on direct and dedicated compute queues, including the adjacent slices and mip. The full texture UAV test also passed 14 GPU cases, 10 compared with WARP, on both GPUs. - Both GPUs accepted a predicate on direct and compute lists using the graphics family, then refused a predicated staged clear. On the dedicated compute families the existing backend refused predicate capture before clear replay. - Regression controls caught both undersized and oversized untagged descriptor depths. Omitting the mip-1 RGB9E5 Uint write left 48 incorrect bytes in the seeded slice. - The RTX 5080 skipped the native RGB9E5 render-target probe in both modes. Radeon failed the existing default D32 NaN depth-clear test in both modes (15 texels read `1`, WARP expected NaN). Both outcomes reproduced on unmodified `0d80bc5df`. The 3D UAV clear tests passed in all four configurations. GPUs tested: NVIDIA GeForce RTX 5080, driver 616.64, Vulkan 1.4.351; AMD Radeon(TM) Graphics, driver 25.10.30.02 (Windows 32.0.21030.2001), Vulkan 1.4.315. Both on Windows 11 Pro build 26200. AI-assisted: yes (Gemini, Codex, Claude) ### Checklist - [x] Based on current `main` at `0d80bc5df`. - [x] One topic, 3D UAV clear ranges and rectangles. - [x] No game data, keys or decryption. The repository content check passed for every changed file. - [x] Translator contract table — not applicable to this runtime-only change.
madvillain91 commented 2026-11-25 14:56:49 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by madvillain91 on 2026-11-25T14:56:49Z.

Review: COMMENTED


Reviewed diff and independently verified commit 926e9d3ef on Windows 11 with an NVIDIA Ampere GPU (against main 71a769d7d):

Environment

  • OS: Windows 11 26H2 (build 26300.9711)
  • Compiler: VS 2022 Build Tools (MSVC 19.44.35230.0, Ninja, RelWithDebInfo)
  • Vulkan SDK: 1.4.363.0
  • GPU: NVIDIA GeForce RTX 3070 Ti (Ampere, 8192 MiB), driver 617.14, Vulkan 1.4.351

Checks run

  • git diff --check: clean
  • Built replay_uav_clear_offset_test, d3d12_uav_clear_test, and d3d12_texture_uav_test cleanly in an isolated build: 0 errors
  • replay_uav_clear_offset_test: PASS (buffer offsets, typeless texture view-format clears, and 3D sliced/rect clears all passed)
  • d3d12_uav_clear_test (plain, LEONIDA_VK_VALIDATION=1, and LEONIDA_VK_VALIDATION=1 + VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT): PASS, 0 VUIDs across all 3 modes (A4B4G4R4_UNORM skipped as no typed UAV on this device; 3D UAV predication predicate control passed and staged clear refused on both direct family 0 and compute family 0)
  • d3d12_texture_uav_test --descriptors-only (LEONIDA_VK_VALIDATION=1 and LEONIDA_VK_VALIDATION=1 + synchronization validation): PASS, 0 VUIDs (texture UAV descriptors: creation, copy, range/refusal and clear checks passed)

Diff notes

  • volume_clear_tile() keeps every tile pattern within the 64 KiB vkCmdUpdateBuffer limit and reuses the private scratch buffer across disjoint XY tiles and Z slices; emit_commands() inserts a transfer barrier before each clipped rectangle to order overlapping rects and scratch fill/update.
  • clear_unordered_access() restricts to DIRECT/COMPUTE lists, and untagged 3D T#s derive mip depth from resource->GetDesc().DepthOrArraySize >> first_mip rather than raw descriptor depth.
  • Predicated staged clears and incompatible 3D view/backing formats (except emulated R9G9B9E5 on R32_UINT) are cleanly refused before submission.

Not checked

  • Full d3d12_texture_uav_test <cs_texture_uav.spv> compute shader invocation, full ctest suite, and non-NVIDIA hardware.

LGTM from this Windows 11 + NVIDIA RTX 3070 Ti verification (AI-assisted verification; synthetic test fixtures only, no game data).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6059983783 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1814#pullrequestreview-6059983783). Originally posted by [madvillain91](https://github.com/madvillain91) on 2026-11-25T14:56:49Z. **Review:** COMMENTED --- Reviewed diff and independently verified commit `926e9d3ef` on Windows 11 with an NVIDIA Ampere GPU (against `main` `71a769d7d`): ### Environment - OS: Windows 11 26H2 (build 26300.9711) - Compiler: VS 2022 Build Tools (MSVC `19.44.35230.0`, Ninja, `RelWithDebInfo`) - Vulkan SDK: `1.4.363.0` - GPU: NVIDIA GeForce RTX 3070 Ti (Ampere, 8192 MiB), driver `617.14`, Vulkan `1.4.351` ### Checks run - `git diff --check`: clean - Built `replay_uav_clear_offset_test`, `d3d12_uav_clear_test`, and `d3d12_texture_uav_test` cleanly in an isolated build: 0 errors - `replay_uav_clear_offset_test`: **PASS** (`buffer offsets, typeless texture view-format clears, and 3D sliced/rect clears all passed`) - `d3d12_uav_clear_test` (plain, `LEONIDA_VK_VALIDATION=1`, and `LEONIDA_VK_VALIDATION=1` + `VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT`): **PASS, 0 VUIDs** across all 3 modes (`A4B4G4R4_UNORM` skipped as no typed UAV on this device; `3D UAV predication` predicate control passed and staged clear refused on both direct family 0 and compute family 0) - `d3d12_texture_uav_test --descriptors-only` (`LEONIDA_VK_VALIDATION=1` and `LEONIDA_VK_VALIDATION=1` + synchronization validation): **PASS, 0 VUIDs** (`texture UAV descriptors: creation, copy, range/refusal and clear checks passed`) ### Diff notes - `volume_clear_tile()` keeps every tile pattern within the 64 KiB `vkCmdUpdateBuffer` limit and reuses the private scratch buffer across disjoint XY tiles and Z slices; `emit_commands()` inserts a transfer barrier before each clipped rectangle to order overlapping rects and scratch fill/update. - `clear_unordered_access()` restricts to `DIRECT`/`COMPUTE` lists, and untagged 3D T#s derive mip depth from `resource->GetDesc().DepthOrArraySize >> first_mip` rather than raw descriptor depth. - Predicated staged clears and incompatible 3D view/backing formats (except emulated `R9G9B9E5` on `R32_UINT`) are cleanly refused before submission. ### Not checked - Full `d3d12_texture_uav_test <cs_texture_uav.spv>` compute shader invocation, full `ctest` suite, and non-NVIDIA hardware. LGTM from this Windows 11 + NVIDIA RTX 3070 Ti verification (AI-assisted verification; synthetic test fixtures only, no game data).
aslan2142 commented 2026-11-25 19:29:11 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-25T19:29:11Z.


Merged, thanks! Tested 926e9d3ef merged onto main with the UAV area tests and the full Windows suite under Wine (llvmpipe and a RADV iGPU). The full suite matches main test by test. The d3d12_clear and d3d12_view_slices failures there fail on main too, with the same messages; they come from the headless test display.

  • Checked on main 75a41f5dc + 926e9d3ef: it merges cleanly; the semantic suite passes (491 files, 6,312 tests, 0 files failed); the 15 docs and writer tests pass; check_no_game_data.py is clean on the 9 changed files.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7172363743 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1814#issuecomment-7172363743). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-25T19:29:11Z. --- Merged, thanks! Tested `926e9d3ef` merged onto `main` with the UAV area tests and the full Windows suite under Wine (llvmpipe and a RADV iGPU). The full suite matches `main` test by test. The `d3d12_clear` and `d3d12_view_slices` failures there fail on `main` too, with the same messages; they come from the headless test display. - **Checked on `main` `75a41f5dc` + `926e9d3ef`:** it merges cleanly; the semantic suite passes (491 files, 6,312 tests, 0 files failed); the 15 docs and writer tests pass; `check_no_game_data.py` is clean on the 9 changed files. AI-assisted (Claude Code, Claude Opus 5.5).
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!1814
No description provided.