diff options
Diffstat (limited to 'adapters/fparkan-render-vulkan/src')
| -rw-r--r-- | adapters/fparkan-render-vulkan/src/ffi/tests.rs | 39 | ||||
| -rw-r--r-- | adapters/fparkan-render-vulkan/src/policy.rs | 24 |
2 files changed, 58 insertions, 5 deletions
diff --git a/adapters/fparkan-render-vulkan/src/ffi/tests.rs b/adapters/fparkan-render-vulkan/src/ffi/tests.rs index 6cf070e..791fff8 100644 --- a/adapters/fparkan-render-vulkan/src/ffi/tests.rs +++ b/adapters/fparkan-render-vulkan/src/ffi/tests.rs @@ -321,6 +321,45 @@ fn capability_gate_respects_request_specific_depth_profiles() { } #[test] +fn depth_attachment_selection_is_canonical_and_request_scoped() { + let supported = [ + vk::Format::D32_SFLOAT_S8_UINT.as_raw(), + vk::Format::D24_UNORM_S8_UINT.as_raw(), + vk::Format::D32_SFLOAT.as_raw(), + ]; + assert_eq!( + select_depth_stencil_attachment_format( + &supported, + DepthStencilSupport { + depth_bits: 24, + stencil_bits: 8, + }, + ), + Some(vk::Format::D24_UNORM_S8_UINT.as_raw()) + ); + assert_eq!( + select_depth_stencil_attachment_format( + &supported, + DepthStencilSupport { + depth_bits: 32, + stencil_bits: 0, + }, + ), + Some(vk::Format::D32_SFLOAT.as_raw()) + ); + assert_eq!( + select_depth_stencil_attachment_format( + &supported, + DepthStencilSupport { + depth_bits: 0, + stencil_bits: 0, + }, + ), + None + ); +} + +#[test] fn capability_report_preserves_informational_sampled_formats_and_limits() { let report = select_physical_device(&[device( "Telemetry GPU", diff --git a/adapters/fparkan-render-vulkan/src/policy.rs b/adapters/fparkan-render-vulkan/src/policy.rs index 38650c6..bb26aee 100644 --- a/adapters/fparkan-render-vulkan/src/policy.rs +++ b/adapters/fparkan-render-vulkan/src/policy.rs @@ -806,11 +806,25 @@ fn supports_depth_stencil_request( if depth.depth_bits == 0 && depth.stencil_bits == 0 { return true; } - required_depth_stencil_formats(depth).iter().any(|format| { - device - .supported_depth_stencil_formats - .contains(&format.as_raw()) - }) + select_depth_stencil_attachment_format(&device.supported_depth_stencil_formats, depth).is_some() +} + +/// Selects the first canonical depth/stencil attachment format supported by a device. +/// +/// The order is part of the Windows Vulkan compatibility contract and is shared +/// by device admission and future render-pass allocation. +#[must_use] +pub fn select_depth_stencil_attachment_format( + supported_formats: &[i32], + depth: DepthStencilSupport, +) -> Option<i32> { + if depth.depth_bits == 0 && depth.stencil_bits == 0 { + return None; + } + required_depth_stencil_formats(depth) + .iter() + .map(|format| format.as_raw()) + .find(|format| supported_formats.contains(format)) } fn informational_capabilities( |
