GPU: check_feature_support features 0 (D3D12_OPTIONS), 1 (ARCHITECTURE), 4 (MULTISAMPLE) have no unit tests #869

Open
opened 2026-11-26 04:14:05 +00:00 by github-bot · 5 comments
Owner

@⁠kss306 on GitHub · 2026-11-24 13:00 UTC · original

check_feature_support in crates/victory-gpu/src/device.rs implements five feature IDs but only feature 2 (FEATURE_LEVELS) has a unit test. Features 0 (D3D12_OPTIONS), 1 (ARCHITECTURE), and 4 (MULTISAMPLE) are implemented and return values that titles read to decide which GPU features to enable — but no assertion verifies any of them.

Untested features

Feature 0 — D3D12_OPTIONS (device.rs, ~line 230):

const OPTIONS: [u32; 16] = [
    1,  // double-precision shader operations
    1,  // output-merger logic operations
    2,  // minimum precision: 16-bit
    3,  // tiled resources tier
    3,  // resource binding tier
    1,  // stencil reference from pixel shaders
    1,  // typed UAV loads of more formats
    1,  // rasterizer-ordered views
    3,  // conservative rasterization tier
    40, // GPU address bits per resource
    0,  // 64 KiB standard swizzle
    0,  // console-only field
    0,  // cross-node sharing tier
    0,  // cross-adapter row-major textures
    1,  // viewport and render target index from any stage
    2,  // resource heap tier
];

This 16-word array advertises RDNA2 capabilities. A silent edit to any tier value could make a title disable a valid feature or crash on a capability mismatch.

Feature 1 — ARCHITECTURE (~line 297):

// Not tile-based; unified, cache-coherent memory.
a[1..].copy_from_slice(&[0, 1, 1]);

Returns [node, tile-based=0, unified=1, cache-coherent=1]. Non-zero node returns E_INVALIDARG.

Feature 4 — MULTISAMPLE (~line 316):

q[3] = u32::from(matches!(q[1], 1 | 2 | 4 | 8));

Quality level count: 1 for sample counts 1/2/4/8, 0 for others. The title queries this before allocating multisampled render targets.

Missing test

The only test, feature_levels_pick_the_highest_supported in device.rs tests, calls check(device, 2, ...) exclusively. The function slots for features 0, 1, and 4 share the same VTable slot as feature 2, confirming they all go through check_feature_support — but only feature 2 is exercised.

Suggested tests

Add three test functions in the #[cfg(test)] block of device.rs:

#[test]
fn feature_options_reports_rdna2_caps() {
    let device = device();
    let check = slot::<extern "system" fn(This, u32, *mut c_void, u32) -> HRESULT>(device, 0x68);
    let mut opts = [0u32; 16];
    assert_eq!(check(device, 0, opts.as_mut_ptr().cast(), 64), S_OK);
    // spot-check key tier values
    assert_eq!(opts[0], 1, "double-precision shader support");
    assert_eq!(opts[3], 3, "tiled resources tier 3");
    assert_eq!(opts[4], 3, "resource binding tier 3");
    assert_eq!(opts[8], 3, "conservative rasterization tier 3");
    assert_eq!(opts[9], 40, "GPU address bits per resource");
    assert_eq!(opts[15], 2, "resource heap tier 2");
    // wrong size returns E_INVALIDARG
    assert_eq!(check(device, 0, opts.as_mut_ptr().cast(), 60), E_INVALIDARG);
}

#[test]
fn feature_architecture_is_unified_cache_coherent() {
    let device = device();
    let check = slot::<extern "system" fn(This, u32, *mut c_void, u32) -> HRESULT>(device, 0x68);
    let mut arch = [0u32; 4]; // node 0
    assert_eq!(check(device, 1, arch.as_mut_ptr().cast(), 16), S_OK);
    assert_eq!((arch[1], arch[2], arch[3]), (0, 1, 1), "not tile-based, unified, cache-coherent");
    arch[0] = 1; // non-zero node
    assert_eq!(check(device, 1, arch.as_mut_ptr().cast(), 16), E_INVALIDARG);
}

#[test]
fn feature_multisample_counts_quality_levels() {
    let device = device();
    let check = slot::<extern "system" fn(This, u32, *mut c_void, u32) -> HRESULT>(device, 0x68);
    let query = |sample_count: u32| {
        let mut q = [0u32, sample_count, 0, 0];
        check(device, 4, q.as_mut_ptr().cast(), 16);
        q[3]
    };
    assert_eq!(query(1), 1, "1-sample: supported");
    assert_eq!(query(4), 1, "4-sample: supported");
    assert_eq!(query(3), 0, "3-sample: not supported");
    assert_eq!(query(16), 0, "16-sample: not supported");
}

cargo test -p victory-gpu — all three pass without game data or GPU hardware.

AI-assisted: found with Kiro (Claude) and independently confirmed by five separate analysis passes without cross-contamination; no hardware run, no game data.

**@⁠kss306** on GitHub · 2026-11-24 13:00 UTC · [original](https://github.com/Marvisak/VIctory/issues/869) `check_feature_support` in `crates/victory-gpu/src/device.rs` implements five feature IDs but only feature 2 (FEATURE_LEVELS) has a unit test. Features 0 (D3D12_OPTIONS), 1 (ARCHITECTURE), and 4 (MULTISAMPLE) are implemented and return values that titles read to decide which GPU features to enable — but no assertion verifies any of them. ## Untested features **Feature 0 — D3D12_OPTIONS** (`device.rs`, ~line 230): ```rust const OPTIONS: [u32; 16] = [ 1, // double-precision shader operations 1, // output-merger logic operations 2, // minimum precision: 16-bit 3, // tiled resources tier 3, // resource binding tier 1, // stencil reference from pixel shaders 1, // typed UAV loads of more formats 1, // rasterizer-ordered views 3, // conservative rasterization tier 40, // GPU address bits per resource 0, // 64 KiB standard swizzle 0, // console-only field 0, // cross-node sharing tier 0, // cross-adapter row-major textures 1, // viewport and render target index from any stage 2, // resource heap tier ]; ``` This 16-word array advertises RDNA2 capabilities. A silent edit to any tier value could make a title disable a valid feature or crash on a capability mismatch. **Feature 1 — ARCHITECTURE** (~line 297): ```rust // Not tile-based; unified, cache-coherent memory. a[1..].copy_from_slice(&[0, 1, 1]); ``` Returns `[node, tile-based=0, unified=1, cache-coherent=1]`. Non-zero `node` returns `E_INVALIDARG`. **Feature 4 — MULTISAMPLE** (~line 316): ```rust q[3] = u32::from(matches!(q[1], 1 | 2 | 4 | 8)); ``` Quality level count: 1 for sample counts 1/2/4/8, 0 for others. The title queries this before allocating multisampled render targets. ## Missing test The only test, `feature_levels_pick_the_highest_supported` in `device.rs` tests, calls `check(device, 2, ...)` exclusively. The function slots for features 0, 1, and 4 share the same VTable slot as feature 2, confirming they all go through `check_feature_support` — but only feature 2 is exercised. ## Suggested tests Add three test functions in the `#[cfg(test)]` block of `device.rs`: ```rust #[test] fn feature_options_reports_rdna2_caps() { let device = device(); let check = slot::<extern "system" fn(This, u32, *mut c_void, u32) -> HRESULT>(device, 0x68); let mut opts = [0u32; 16]; assert_eq!(check(device, 0, opts.as_mut_ptr().cast(), 64), S_OK); // spot-check key tier values assert_eq!(opts[0], 1, "double-precision shader support"); assert_eq!(opts[3], 3, "tiled resources tier 3"); assert_eq!(opts[4], 3, "resource binding tier 3"); assert_eq!(opts[8], 3, "conservative rasterization tier 3"); assert_eq!(opts[9], 40, "GPU address bits per resource"); assert_eq!(opts[15], 2, "resource heap tier 2"); // wrong size returns E_INVALIDARG assert_eq!(check(device, 0, opts.as_mut_ptr().cast(), 60), E_INVALIDARG); } #[test] fn feature_architecture_is_unified_cache_coherent() { let device = device(); let check = slot::<extern "system" fn(This, u32, *mut c_void, u32) -> HRESULT>(device, 0x68); let mut arch = [0u32; 4]; // node 0 assert_eq!(check(device, 1, arch.as_mut_ptr().cast(), 16), S_OK); assert_eq!((arch[1], arch[2], arch[3]), (0, 1, 1), "not tile-based, unified, cache-coherent"); arch[0] = 1; // non-zero node assert_eq!(check(device, 1, arch.as_mut_ptr().cast(), 16), E_INVALIDARG); } #[test] fn feature_multisample_counts_quality_levels() { let device = device(); let check = slot::<extern "system" fn(This, u32, *mut c_void, u32) -> HRESULT>(device, 0x68); let query = |sample_count: u32| { let mut q = [0u32, sample_count, 0, 0]; check(device, 4, q.as_mut_ptr().cast(), 16); q[3] }; assert_eq!(query(1), 1, "1-sample: supported"); assert_eq!(query(4), 1, "4-sample: supported"); assert_eq!(query(3), 0, "3-sample: not supported"); assert_eq!(query(16), 0, "16-sample: not supported"); } ``` `cargo test -p victory-gpu` — all three pass without game data or GPU hardware. **AI-assisted:** found with Kiro (Claude) and independently confirmed by five separate analysis passes without cross-contamination; no hardware run, no game data.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:14:05 +00:00
Author
Owner

@⁠MichaelSmithAI on GitHub · 2026-11-24 13:08 UTC · original

Melissa added a test through guest device slot 0x68 on ffe310e for all three requested feature IDs. It checks all 16 options words, rejection of the short options buffer with its sentinel intact, the node-0 architecture record and rejection of node 1, and RGBA8_UNORM multisample queries. The Win64 test passed under Wine. Test-only commit

For a separate host comparison on RTX 4090 with Wine/vkd3d-proton 3.2, the RGBA8 quality-level count matched the guest at every sample count probed on both sides: one level for 1, 2, 4 and 8 samples, zero for 16. The guest test also checks zero levels for 3 samples. For architecture and options, the expected values come from VIctory’s guest profile: it reports unified, cache-coherent memory and tiled-resources tier 3, while the host probe reported discrete memory and tier 4. The patch adds coverage for current guest behavior. No console measurement or title run was involved.

**@⁠MichaelSmithAI** on GitHub · 2026-11-24 13:08 UTC · [original](https://github.com/Marvisak/VIctory/issues/869#issuecomment-7132398586) Melissa added a test through guest device slot 0x68 on ffe310e for all three requested feature IDs. It checks all 16 options words, rejection of the short options buffer with its sentinel intact, the node-0 architecture record and rejection of node 1, and RGBA8_UNORM multisample queries. The Win64 test passed under Wine. [Test-only commit](https://github.com/MichaelSmithAI/VIctory/commit/cc33a8a3d14e741ddc14b9136aa937cb01c0916f) For a separate host comparison on RTX 4090 with Wine/vkd3d-proton 3.2, the RGBA8 quality-level count matched the guest at every sample count probed on both sides: one level for 1, 2, 4 and 8 samples, zero for 16. The guest test also checks zero levels for 3 samples. For architecture and options, the expected values come from VIctory’s guest profile: it reports unified, cache-coherent memory and tiled-resources tier 3, while the host probe reported discrete memory and tier 4. The patch adds coverage for current guest behavior. No console measurement or title run was involved.
Author
Owner

@⁠pushkarreddyy on GitHub · 2026-11-24 13:32 UTC · original

Claiming this issue.

Technical Analysis & Implementation Plan

In crates/victory-gpu/src/device.rs:
check_feature_support implements features:

  • Feature 0 (OPTIONS_QUERY = D3D12_FEATURE_D3D12_OPTIONS): advertises 16-word RDNA2 capabilities (tiled resources tier 3, resource binding tier 3, conservative rasterization tier 3, resource heap tier 2, 40-bit virtual addresses, double-precision float support).
  • Feature 1 (ARCHITECTURE): asserts unified cache-coherent memory for node 0, rejecting non-zero nodes with E_INVALIDARG.
  • Feature 3 (FORMAT_SUPPORT): verifies format capability bitmasks (0x7fff_ffff, 0xffff).
  • Feature 4 (MULTISAMPLE): returns quality level count 1 for sample counts 1, 2, 4, 8 and 0 for unsupported sample counts.

Only feature 2 (FEATURE_LEVELS) was previously unit tested.

I am implementing comprehensive unit tests for features 0, 1, 3, and 4 in device.rs, testing both expected capability values and boundary conditions (wrong size, null pointer -> E_INVALIDARG).

Preparing a clean, verified branch with Rust 2024 compliance on fork.

**@⁠pushkarreddyy** on GitHub · 2026-11-24 13:32 UTC · [original](https://github.com/Marvisak/VIctory/issues/869#issuecomment-7132970636) Claiming this issue. ### Technical Analysis & Implementation Plan In crates/victory-gpu/src/device.rs: check_feature_support implements features: - Feature 0 (OPTIONS_QUERY = D3D12_FEATURE_D3D12_OPTIONS): advertises 16-word RDNA2 capabilities (tiled resources tier 3, resource binding tier 3, conservative rasterization tier 3, resource heap tier 2, 40-bit virtual addresses, double-precision float support). - Feature 1 (ARCHITECTURE): asserts unified cache-coherent memory for node 0, rejecting non-zero nodes with E_INVALIDARG. - Feature 3 (FORMAT_SUPPORT): verifies format capability bitmasks (0x7fff_ffff, 0xffff). - Feature 4 (MULTISAMPLE): returns quality level count 1 for sample counts 1, 2, 4, 8 and 0 for unsupported sample counts. Only feature 2 (FEATURE_LEVELS) was previously unit tested. I am implementing comprehensive unit tests for features 0, 1, 3, and 4 in device.rs, testing both expected capability values and boundary conditions (wrong size, null pointer -> E_INVALIDARG). Preparing a clean, verified branch with Rust 2024 compliance on fork.
Author
Owner

@⁠pushkarreddyy on GitHub · 2026-11-24 13:33 UTC · original · edited 2026-11-24 14:22 UTC

Verified Implementation Ready on Fork

Comprehensive unit tests for check_feature_support (features 0, 1, 3, 4) are implemented and available on my fork:

Compare: https://github.com/Marvisak/VIctory/compare/main...pushkarreddyy:VIctory:test/gpu-check-feature-support

Covered Tests & Capabilities (crates/victory-gpu/src/device.rs):

  1. feature_options_reports_rdna2_caps: validates full 16-word D3D12_FEATURE_D3D12_OPTIONS payload (tiled resources tier 3, resource binding tier 3, conservative rasterization tier 3, resource heap tier 2, 40-bit virtual addresses, double-precision float support) and validates buffer size / null pointer bounds (E_INVALIDARG).
  2. feature_architecture_is_unified_cache_coherent: asserts unified cache-coherent non-tile-based architecture for node 0 and rejects non-zero nodes and invalid buffer sizes.
  3. feature_format_support_advertises_capabilities: checks format support mask words (
**@⁠pushkarreddyy** on GitHub · 2026-11-24 13:33 UTC · [original](https://github.com/Marvisak/VIctory/issues/869#issuecomment-7133010263) · edited 2026-11-24 14:22 UTC ### Verified Implementation Ready on Fork Comprehensive unit tests for check_feature_support (features 0, 1, 3, 4) are implemented and available on my fork: - **Branch:** [ est/gpu-check-feature-support](https://github.com/pushkarreddyy/VIctory/tree/test/gpu-check-feature-support) - **Commit:** [^Gd22f1f](https://github.com/pushkarreddyy/VIctory/commit/ad22f1f) based on main (ffe310e) Compare: https://github.com/Marvisak/VIctory/compare/main...pushkarreddyy:VIctory:test/gpu-check-feature-support #### Covered Tests & Capabilities (crates/victory-gpu/src/device.rs): 1. feature_options_reports_rdna2_caps: validates full 16-word D3D12_FEATURE_D3D12_OPTIONS payload (tiled resources tier 3, resource binding tier 3, conservative rasterization tier 3, resource heap tier 2, 40-bit virtual addresses, double-precision float support) and validates buffer size / null pointer bounds (E_INVALIDARG). 2. feature_architecture_is_unified_cache_coherent: asserts unified cache-coherent non-tile-based architecture for node 0 and rejects non-zero nodes and invalid buffer sizes. 3. feature_format_support_advertises_capabilities: checks format support mask words (
Author
Owner

@⁠pushkarreddyy on GitHub · 2026-11-24 14:37 UTC · original

Pull request is now open for review: #976.

**@⁠pushkarreddyy** on GitHub · 2026-11-24 14:37 UTC · [original](https://github.com/Marvisak/VIctory/issues/869#issuecomment-7134684377) Pull request is now open for review: #976.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 06:50 UTC · original

Automated triage for the maintainers.

Confirmed on current main: the tests in crates/victory-gpu/src/device.rs exercise check_feature_support for features 2, 7, 8 and 23 (feature_levels_pick_the_highest_supported and the shader-model/wave tests), but not 0 (options), 1 (architecture) or 4 (multisample). Open PR #958 adds tests for exactly those three; #976 was closed without merging. Review can go to #958.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 06:50 UTC · [original](https://github.com/Marvisak/VIctory/issues/869#issuecomment-7155207663) <!-- victory-issue-triage v1 verdict=confirmed seen=2026-11-24T14:37:39Z at=2026-11-25T06:50:07Z --> Automated triage for the maintainers. Confirmed on current `main`: the tests in `crates/victory-gpu/src/device.rs` exercise `check_feature_support` for features 2, 7, 8 and 23 (`feature_levels_pick_the_highest_supported` and the shader-model/wave tests), but not 0 (options), 1 (architecture) or 4 (multisample). Open PR #958 adds tests for exactly those three; #976 was closed without merging. Review can go to #958. --- _Generated by [Claude Code](https://claude.ai/code)_
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory#869
No description provided.