GPU: check typed buffer format support before creating descriptors #74

Merged
mattiolocoding merged 1 commit from upstream-pr/74 into main 2026-11-28 19:01:28 +00:00
mattiolocoding commented 2026-11-27 16:34:12 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by mattiolocoding on 2026-11-27T16:34:12Z.


A typed buffer view can fit its allocation and still use a format the host cannot expose as a buffer. On an RTX 3060 Ti, buffer_view_ok(R8G8B8A8_UNORM_SRGB, 0, 16, 0, false, 4096) currently returns true even though the device reports no D3D12_FORMAT_SUPPORT1_BUFFER for that format. Both buffer creation paths rely on this guard before calling the void D3D12 descriptor creation methods.

This extends the guard with the host's format capabilities:

  • Typed SRVs require BUFFER; typed UAVs require both BUFFER and TYPED_UNORDERED_ACCESS_VIEW.
  • Each format is queried once with CheckFeatureSupport, cached with a per-format OnceLock. Failed queries reject the view.
  • Raw and structured views retain their existing checks. Rejected requests follow the existing null-view path and refusal counters.

The capability flags are documented in D3D12_FORMAT_SUPPORT1; the format support tables list sRGB and depth examples without buffer support. Unsupported typed formats still need conversion support to render their contents; this change keeps their descriptors away from the driver.

Validation on Windows 11, RTX 3060 Ti 8 GB, driver 617.14, Rust 1.98.1, based on d12eb1b:

  • Regression added alone to the base: formats_without_buffer_support_fail_the_host_check fails with format 29 has no buffer support, but its view passed validation.
  • With the fix: all 50 descriptor::host::tests:: tests pass, including three new tests for unsupported buffer formats, SRV versus UAV capabilities, and valid typed views and their bounds. Hardware checks ran; the regression did not skip for lack of a device.
  • Native release build of the application and test executable succeeds, with diagnostics,blake3/pure. Command: cargo test --locked --release -p victory-gpu --features diagnostics,blake3/pure --lib descriptor::host::tests:: -- --test-threads=1.
  • cargo clippy --locked --release -p victory-gpu --all-targets --features diagnostics,blake3/pure --message-format=json --no-deps completes. Base and branch have exactly the same 59 warning diagnostics (28 unique), compared by message, lint code and primary source file. No warnings added; the base's existing warnings remain relevant to CI's -D warnings setting.
  • cargo run --locked --release -p xtask -- policy passes; git diff --check passes.
  • A locally supplied Series S dump binds with zero missing imports. A subsequent smoke run on the same RTX 3060 Ti, with the Series S profile, a 30 FPS cap and DLSS and frame generation disabled, rendered the local profile selector and initial setup through the privacy and Terms of Service screen. Over 4,000 presents were logged, with no device-removal or descriptor-slot exhaustion messages. The layered runtime suspended and saved its pipeline library on close. Coverage ends at initial setup. The in-world renderer still needs a gameplay run.

Only synthetic tests and interoperability constants are added. No game files or derived assets are included. AI-assisted with Codex.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5529988704 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/74). Originally posted by [mattiolocoding](https://github.com/mattiolocoding) on 2026-11-27T16:34:12Z. --- A typed buffer view can fit its allocation and still use a format the host cannot expose as a buffer. On an RTX 3060 Ti, `buffer_view_ok(R8G8B8A8_UNORM_SRGB, 0, 16, 0, false, 4096)` currently returns true even though the device reports no `D3D12_FORMAT_SUPPORT1_BUFFER` for that format. Both buffer creation paths rely on this guard before calling the void D3D12 descriptor creation methods. This extends the guard with the host's format capabilities: - Typed SRVs require `BUFFER`; typed UAVs require both `BUFFER` and `TYPED_UNORDERED_ACCESS_VIEW`. - Each format is queried once with `CheckFeatureSupport`, cached with a per-format `OnceLock`. Failed queries reject the view. - Raw and structured views retain their existing checks. Rejected requests follow the existing null-view path and refusal counters. The capability flags are documented in [D3D12_FORMAT_SUPPORT1](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ne-d3d12-d3d12_format_support1); the [format support tables](https://learn.microsoft.com/en-us/windows/win32/direct3ddxgi/hardware-support-for-direct3d-12-1-formats) list sRGB and depth examples without buffer support. Unsupported typed formats still need conversion support to render their contents; this change keeps their descriptors away from the driver. Validation on Windows 11, RTX 3060 Ti 8 GB, driver 617.14, Rust 1.98.1, based on `d12eb1b`: - Regression added alone to the base: `formats_without_buffer_support_fail_the_host_check` fails with `format 29 has no buffer support, but its view passed validation`. - With the fix: all 50 `descriptor::host::tests::` tests pass, including three new tests for unsupported buffer formats, SRV versus UAV capabilities, and valid typed views and their bounds. Hardware checks ran; the regression did not skip for lack of a device. - Native release build of the application and test executable succeeds, with `diagnostics,blake3/pure`. Command: `cargo test --locked --release -p victory-gpu --features diagnostics,blake3/pure --lib descriptor::host::tests:: -- --test-threads=1`. - `cargo clippy --locked --release -p victory-gpu --all-targets --features diagnostics,blake3/pure --message-format=json --no-deps` completes. Base and branch have exactly the same 59 warning diagnostics (28 unique), compared by message, lint code and primary source file. No warnings added; the base's existing warnings remain relevant to CI's `-D warnings` setting. - `cargo run --locked --release -p xtask -- policy` passes; `git diff --check` passes. - A locally supplied Series S dump binds with zero missing imports. A subsequent smoke run on the same RTX 3060 Ti, with the Series S profile, a 30 FPS cap and DLSS and frame generation disabled, rendered the local profile selector and initial setup through the privacy and Terms of Service screen. Over 4,000 presents were logged, with no device-removal or descriptor-slot exhaustion messages. The layered runtime suspended and saved its pipeline library on close. **Coverage ends at initial setup.** The in-world renderer still needs a gameplay run. Only synthetic tests and interoperability constants are added. No game files or derived assets are included. AI-assisted with Codex.
Kal0s-design commented 2026-11-27 17:24:05 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Kal0s-design on 2026-11-27T17:24:05Z.


Verified on NVIDIA (real D3D12 device, pinned 1.98.1 toolchain, offline build).

The PR touches one file, so I took its crates/victory-gpu/src/descriptor/host.rs onto current main (29d8dbf). That file is unchanged on main since the branch point (1124487), so it applies clean.

Tests (cargo test -p victory-gpu --lib descriptor::host::tests::): 50/50 pass, including the three new ones (formats_without_buffer_support_fail_the_host_check, a_srv_buffer_format_is_not_necessarily_a_uav_format, supported_typed_buffer_views_stay_available) and the updated buffer_view_ok signature test.

Sensitivity: dropping just the new format-support clause (so buffer_view_ok behaves as before) fails two of those tests on this device, so the over-acceptance is not only on the 3060 Ti in the description:

  • R8G8B8A8_UNORM_SRGB (format 29) reports no D3D12_FORMAT_SUPPORT1_BUFFER here, yet the old guard accepted a typed SRV for it.
  • R32G32B32_FLOAT reports BUFFER but not TYPED_UNORDERED_ACCESS_VIEW on this device, so the old guard accepted a typed UAV it should refuse. The new uav flag draws that line.

supported_typed_buffer_views_stay_available passes, so supported formats are untouched.

One note, not a blocker: cargo clippy -p victory-gpu --all-targets -- -D warnings is already red on plain main (39 warnings, all in other files). This change adds none (same 39 with and without it), so it is not clippy-clean through no fault of this PR.

Not covered: the in-game path (no game data here), the WARP/software adapter, and concurrent first-touch of the per-format OnceLock cache.

AI-assisted: yes.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7224363513 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/74#issuecomment-7224363513). Originally posted by [Kal0s-design](https://github.com/Kal0s-design) on 2026-11-27T17:24:05Z. --- Verified on NVIDIA (real D3D12 device, pinned 1.98.1 toolchain, offline build). The PR touches one file, so I took its `crates/victory-gpu/src/descriptor/host.rs` onto current main (`29d8dbf`). That file is unchanged on main since the branch point (`1124487`), so it applies clean. Tests (`cargo test -p victory-gpu --lib descriptor::host::tests::`): 50/50 pass, including the three new ones (`formats_without_buffer_support_fail_the_host_check`, `a_srv_buffer_format_is_not_necessarily_a_uav_format`, `supported_typed_buffer_views_stay_available`) and the updated `buffer_view_ok` signature test. Sensitivity: dropping just the new format-support clause (so `buffer_view_ok` behaves as before) fails two of those tests on this device, so the over-acceptance is not only on the 3060 Ti in the description: - `R8G8B8A8_UNORM_SRGB` (format 29) reports no `D3D12_FORMAT_SUPPORT1_BUFFER` here, yet the old guard accepted a typed SRV for it. - `R32G32B32_FLOAT` reports `BUFFER` but not `TYPED_UNORDERED_ACCESS_VIEW` on this device, so the old guard accepted a typed UAV it should refuse. The new `uav` flag draws that line. `supported_typed_buffer_views_stay_available` passes, so supported formats are untouched. One note, not a blocker: `cargo clippy -p victory-gpu --all-targets -- -D warnings` is already red on plain main (39 warnings, all in other files). This change adds none (same 39 with and without it), so it is not clippy-clean through no fault of this PR. Not covered: the in-game path (no game data here), the WARP/software adapter, and concurrent first-touch of the per-format `OnceLock` cache. AI-assisted: yes.
fladit123 commented 2026-11-27 19:43:04 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by fladit123 on 2026-11-27T19:43:04Z.

Review: APPROVED


APPROVE

Thanks for addressing typed buffer format validation. I independently reviewed and tested the pinned revisions on an RTX 4060 and WARP, extending the previous validation to software-adapter coverage, concurrent cache initialization, and numerical readbacks through the actual descriptor writers.

Reviewed HEAD: 1124487ce19f5c5c4912983f7e15534e4a66aa86.

Baseline: d12eb1b23da4cad2f551a3dd49e82a87e564122a.

Validation

Test RTX 4060 WARP
Existing baseline tests 47/47 47/47
Existing candidate tests 50/50 50/50
Instrumented candidate tests 55/55 55/55
Numerical readbacks across both revisions 12/12 14/14

Adapter identity was verified through the actual D3D12 device LUID in the instrumented runs.

The format matrix covered all 107 IDs known to resource::element, producing 428 records across both revisions and adapters.

Accepted typed formats:

Adapter SRV base/head UAV base/head
RTX 4060 71/44 71/40
WARP 71/49 71/45

The candidate's decisions matched the expected capability masks throughout the tested matrix.

Production-path correctness

The capability cache queries the same process-owned D3D12 device that creates the descriptors.

Three representative unsupported requests per adapter reached the actual descriptor writers and returned before native descriptor creation.

All 26 synthetic readbacks matched their CPU references, including:

  • Typed SRV and UAV operations.
  • Raw buffers.
  • Native structured buffers.
  • Structured-to-raw conversion.
  • RGB565 SRV on WARP.

Raw and structured views retained their existing behavior.

Concurrent initialization

Eight threads contended on four previously untouched format-cache slots per adapter, including an unsupported format.

Each slot produced exactly one native capability query, followed by 160,000 successful warm lookups per adapter in total.

The isolated warm-cache lookup median was approximately 19.48 ns on the RTX 4060 and 21.15 ns on WARP in the instrumented debug build.

These measurements are not end-to-end performance or FPS claims.

Non-blocking follow-up

Format ID 191 has different semantics in the console element table and native DXGI: four bytes versus two bytes for A4B4G4R4_UNORM.

WARP reports support for its native format, while the baseline already accepts this numeric alias. Correct format translation should be investigated separately. Its numerical consequences were not tested here.

Conclusion

No blocking regression was found in the tested scope.

The PR correctly introduces device-specific typed buffer validation while preserving the existing raw and structured paths.

Hardware: RTX 4060, driver 610.88, Windows 11, 32 GB RAM; Microsoft WARP.

All experiments used synthetic graphics workloads only. No game files or execution.

AI-assisted review and testing using OpenAI ChatGPT and Codex.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:review:6092730458 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/74#pullrequestreview-6092730458). Originally posted by [fladit123](https://github.com/fladit123) on 2026-11-27T19:43:04Z. **Review:** APPROVED --- **APPROVE** Thanks for addressing typed buffer format validation. I independently reviewed and tested the pinned revisions on an RTX 4060 and WARP, extending the previous validation to software-adapter coverage, concurrent cache initialization, and numerical readbacks through the actual descriptor writers. Reviewed HEAD: `1124487ce19f5c5c4912983f7e15534e4a66aa86`. Baseline: `d12eb1b23da4cad2f551a3dd49e82a87e564122a`. ### Validation | Test | RTX 4060 | WARP | |---|---:|---:| | Existing baseline tests | 47/47 | 47/47 | | Existing candidate tests | 50/50 | 50/50 | | Instrumented candidate tests | 55/55 | 55/55 | | Numerical readbacks across both revisions | 12/12 | 14/14 | Adapter identity was verified through the actual D3D12 device LUID in the instrumented runs. The format matrix covered all 107 IDs known to `resource::element`, producing 428 records across both revisions and adapters. Accepted typed formats: | Adapter | SRV base/head | UAV base/head | |---|---:|---:| | RTX 4060 | 71/44 | 71/40 | | WARP | 71/49 | 71/45 | The candidate's decisions matched the expected capability masks throughout the tested matrix. ### Production-path correctness The capability cache queries the same process-owned D3D12 device that creates the descriptors. Three representative unsupported requests per adapter reached the actual descriptor writers and returned before native descriptor creation. All 26 synthetic readbacks matched their CPU references, including: - Typed SRV and UAV operations. - Raw buffers. - Native structured buffers. - Structured-to-raw conversion. - RGB565 SRV on WARP. Raw and structured views retained their existing behavior. ### Concurrent initialization Eight threads contended on four previously untouched format-cache slots per adapter, including an unsupported format. Each slot produced exactly one native capability query, followed by 160,000 successful warm lookups per adapter in total. The isolated warm-cache lookup median was approximately 19.48 ns on the RTX 4060 and 21.15 ns on WARP in the instrumented debug build. These measurements are not end-to-end performance or FPS claims. ### Non-blocking follow-up Format ID 191 has different semantics in the console element table and native DXGI: four bytes versus two bytes for `A4B4G4R4_UNORM`. WARP reports support for its native format, while the baseline already accepts this numeric alias. Correct format translation should be investigated separately. Its numerical consequences were not tested here. ### Conclusion No blocking regression was found in the tested scope. The PR correctly introduces device-specific typed buffer validation while preserving the existing raw and structured paths. Hardware: RTX 4060, driver 610.88, Windows 11, 32 GB RAM; Microsoft WARP. All experiments used synthetic graphics workloads only. No game files or execution. AI-assisted review and testing using OpenAI ChatGPT and Codex.
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
trustno1-coder/VIctory-NVIDIA!74
No description provided.