Repository: gfx-rs/wgpu (language: rust)

Issue:
`CheckFeatureSupport` with `D3D12_FEATURE_D3D12_OPTIONS19` returns a zero valued struct
<!-- Thank you for filing this! Please read the [debugging tips](https://github.com/gfx-rs/wgpu/wiki/Debugging-wgpu-Applications).
That may let you investigate on your own, or provide additional information that helps us to assist.-->

**Description**
When calling `device.CheckFeatureSupport` with `D3D12_FEATURE_D3D12_OPTIONS19` it doesn't return an error. This causes `features19.MaxSamplerDescriptorHeapSize` to be zero leading to a zero sized sampler heap being created. On my NVIDIA machine this causes wgpu to seg-fault.

**Repro steps**
Run any example on dx12 using a system with the below info

**Expected vs observed behavior**
Wgpu should never seg-fault

**Extra materials**
Zero value set at 
https://github.com/gfx-rs/wgpu/blob/4e7d892317ea84e2d781106de6387506a6e28d84/wgpu-hal/src/dx12/adapter.rs#L206-L216
Stack:
````
<unknown> 0x00007ffb226a1ffe
<unknown> 0x00007ffb225f1bf3
<unknown> 0x00007ffb22bbdc55
<unknown> 0x00007ffac4fdff1b
<unknown> 0x00007ffac4fdffcd
<unknown> 0x00007ffac4f5d0e0
<unknown> 0x00007ffac4f5ee08
<unknown> 0x00007ffac4f23350
<unknown> 0x00007ffac1a18e0b
<unknown> 0x00007ffac1a0d1c8
<unknown> 0x00007ffac19c6350
<unknown> 0x00007ffb27a21eea
<unknown> 0x00007ffac4f5be7f
<unknown> 0x00007ffac19d048d
windows::Win32::Graphics::Direct3D12::ID3D12Device::CreateDescriptorHeap<windows::Win32::Graphics::Direct3D12::ID3D12DescriptorHeap>(*mut windows::Win32::Graphics::Direct3D12::D3D12_DESCRIPTOR_HEAP_DESC) mod.rs:713
wgpu_hal::dx12::sampler::SamplerHeap::new(*mut wgpu_hal::dx12::PrivateCapabilities) sampler.rs:121
wgpu_hal::dx12::Device::new(windows::Win32::Graphics::Direct3D12::ID3D12Device,windows::Win32::Graphics::Direct3D12::ID3D12CommandQueue,*mut wgpu_types::Limits,*mut enum2$<wgpu_types::MemoryHints>,wgpu_hal::dx12::PrivateCapabilities,*mut alloc::sync::Arc<wgpu_hal::dx12::D3D12Lib,alloc::alloc::Global>,enum2$<core::option::Option<alloc::sync::Arc<wgpu_hal::dx12::shader_compilation::DxcContainer,alloc::alloc::Global> > >) device.rs:147
wgpu_hal::dx12::adapter::impl$2::open(*mut wgpu_hal::dx12::Adapter,wgpu_types::Features,*mut wgpu_types::Limits,*mut enum2$<wgpu_types::MemoryHints>) adapter.rs:618
wgpu_hal::dynamic::adapter::impl$1::open<wgpu_hal::dx12::Adapter>(*mut wgpu_hal::dx12::Adapter,wgpu_types::Features,*mut wgpu_types::Limits,*mut enum2$<wgpu_types::MemoryHints>) adapter.rs:46
wgpu_core::instance::Adapter::create_device_and_queue(*mut wgpu_types::DeviceDescriptor<enum2$<core::option::Option<enum2$<alloc::borrow::Cow<str$> > > > >,wgpu_types::instance::InstanceFlags,enum2$<core::option::Option<ref$<str$> > >) instance.rs:684
wgpu_core::global::Global::adapter_request_device(wgpu_core::id::Id<enum2$<wgpu_core::id::markers::Adapter> >,*mut wgpu_types::DeviceDescriptor<enum2$<core::option::Option<enum2$<alloc::borrow::Cow<str$> > > > >,enum2$<core::option::Option<ref$<str$> > >,enum2$<core::option::Option<wgpu_core::id::Id<enum2$<wgpu_core::id::markers::Device> > > >,enum2$<core::option::Option<wgpu_core::id::Id<enum2$<wgpu_core::id::markers::Queue> > > >) instance.rs:945
wgpu::backend::wgpu_core::impl$11::request_device(*mut wgpu::backend::wgpu_core::CoreAdapter,*mut wgpu_types::DeviceDescriptor<enum2$<core::option::Option<ref$<str$> > > >,enum2$<core::option::Option<ref$<std::path::Path> > >) wgpu_core.rs:880
wgpu::api::adapter::Adapter::request_device(*mut wgpu_types::DeviceDescriptor<enum2$<core::option::Option<ref$<str$> > > >,enum2$<core::option::Option<ref$<std::path::Path> > >) adapter.rs:66
wgpu_examples::framework::impl$2::init_async::async_fn$0<wgpu_examples::ray_cube_compute::Example>(core::pin::Pin<ref_mut$<enum2$<wgpu_examples::framework::impl$2::init_async::async_fn_env$0<wgpu_examples::ray_cube_compute::Example> > > >,*mut core::task::wake::Context) framework.rs:285
wgpu_examples::framework::start::async_fn$0<wgpu_examples::ray_cube_compute::Example>(core::pin::Pin<ref_mut$<enum2$<wgpu_examples::framework::start::async_fn_env$0<wgpu_examples::ray_cube_compute::Example> > > >,*mut core::task::wake::Context) framework.rs:349
pollster::block_on<enum2$<wgpu_examples::framework::start::async_fn_env$0<wgpu_examples::ray_cube_compute::Example> > >(enum2$<wgpu_examples::framework::start::async_fn_env$0<wgpu_examples::ray_cube_compute::Example> >) lib.rs:126
wgpu_examples::framework::run<wgpu_examples::ray_cube_compute::Example>(ref$<str$>) framework.rs:458
wgpu_examples::ray_cube_compute::main() mod.rs:482
wgpu_examples::main() main.rs:253
...
````

Values
![Image](https://github.com/user-attachments/assets/fce6073c-4aa1-40e1-91cc-0cffd960ead7)

**Platform**
Windows 23h2
NVIDIA gpu.


Discussion / hints:

Fix patch:
diff --git a/wgpu-hal/src/dx12/adapter.rs b/wgpu-hal/src/dx12/adapter.rs
index 52ec89ebb9..ad37f6ad0b 100644
--- a/wgpu-hal/src/dx12/adapter.rs
+++ b/wgpu-hal/src/dx12/adapter.rs
@@ -212,7 +212,16 @@ impl super::Adapter {
                 )
             };
 
-            if res.is_ok() {
+            // Sometimes on Windows 11 23H2, the function returns success, even though the runtime
+            // does not know about `Options19`. This can cause this number to be 0 as the structure isn't written to.
+            // This value is nonsense and creating zero-sized sampler heaps can cause drivers to explode.
+            // As as we're guaranteed 2048 anyway, we make sure this value is not under 2048.
+            //
+            // https://github.com/gfx-rs/wgpu/issues/7053
+            let is_ok = res.is_ok();
+            let is_above_minimum = features19.MaxSamplerDescriptorHeapSize
+                > Direct3D12::D3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZE;
+            if is_ok && is_above_minimum {
                 max_sampler_descriptor_heap_size = features19.MaxSamplerDescriptorHeapSize;
             }
         };


Test patch: