From 517018e9aece997b6f6490af6cdef4c8d5c69f98 Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Thu, 22 May 2025 12:51:51 -0400 Subject: [PATCH] refactor(dx12): detect `UnrestrictedBufferTextureCopyPitchSupported` --- wgpu-hal/src/dx12/adapter.rs | 17 +++++++++++++++++ wgpu-hal/src/dx12/mod.rs | 1 + 2 files changed, 18 insertions(+) diff --git a/wgpu-hal/src/dx12/adapter.rs b/wgpu-hal/src/dx12/adapter.rs index 140dcf60a..9d174adf0 100644 --- a/wgpu-hal/src/dx12/adapter.rs +++ b/wgpu-hal/src/dx12/adapter.rs @@ -200,6 +200,21 @@ impl super::Adapter { .is_ok() }; + let unrestricted_buffer_texture_copy_pitch_supported = { + let mut features13 = Direct3D12::D3D12_FEATURE_DATA_D3D12_OPTIONS13::default(); + unsafe { + device.CheckFeatureSupport( + Direct3D12::D3D12_FEATURE_D3D12_OPTIONS13, + <*mut _>::cast(&mut features13), + size_of_val(&features13) as u32, + ) + } + .is_ok() + && features13 + .UnrestrictedBufferTextureCopyPitchSupported + .as_bool() + }; + let mut max_sampler_descriptor_heap_size = Direct3D12::D3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZE; { @@ -304,6 +319,8 @@ impl super::Adapter { suballocation_supported: !info.name.contains("Iris(R) Xe"), shader_model, max_sampler_descriptor_heap_size, + _unrestricted_buffer_texture_copy_pitch_supported: + unrestricted_buffer_texture_copy_pitch_supported, }; // Theoretically vram limited, but in practice 2^20 is the limit diff --git a/wgpu-hal/src/dx12/mod.rs b/wgpu-hal/src/dx12/mod.rs index 125a88287..16c967aa9 100644 --- a/wgpu-hal/src/dx12/mod.rs +++ b/wgpu-hal/src/dx12/mod.rs @@ -601,6 +601,7 @@ struct PrivateCapabilities { suballocation_supported: bool, shader_model: naga::back::hlsl::ShaderModel, max_sampler_descriptor_heap_size: u32, + _unrestricted_buffer_texture_copy_pitch_supported: bool, } #[derive(Default)]