mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-19 14:01:08 +01:00
[d3d12] fix panics in adapter creation (#8845)
This commit is contained in:
1 parent
a6d3f4f819
commit
0cd51d20f3
2 files changed
+37
-16
No files matched your search
@@ -70,14 +70,18 @@ impl super::Adapter {
|
||||
telemetry: Option<crate::Telemetry>,
|
||||
) -> Option<crate::ExposedAdapter<super::Api>> {
|
||||
let desc = unsafe { adapter.GetDesc2() }.unwrap();
|
||||
let driver_version =
|
||||
unsafe { adapter.CheckInterfaceSupport(&Dxgi::IDXGIDevice::IID) }.unwrap() as u64;
|
||||
let driver_version = [
|
||||
(driver_version >> 48) as u16,
|
||||
(driver_version >> 32) as u16,
|
||||
(driver_version >> 16) as u16,
|
||||
driver_version as u16,
|
||||
];
|
||||
let driver_version = unsafe { adapter.CheckInterfaceSupport(&Dxgi::IDXGIDevice::IID) };
|
||||
let driver_version = driver_version
|
||||
.map(|driver_version| {
|
||||
let driver_version = driver_version as u64;
|
||||
[
|
||||
(driver_version >> 48) as u16,
|
||||
(driver_version >> 32) as u16,
|
||||
(driver_version >> 16) as u16,
|
||||
driver_version as u16,
|
||||
]
|
||||
})
|
||||
.map_err(|e| e.code());
|
||||
|
||||
// Create the device so that we can get the capabilities.
|
||||
let res = {
|
||||
@@ -124,7 +128,16 @@ impl super::Adapter {
|
||||
Direct3D::D3D_FEATURE_LEVEL_12_0 => FeatureLevel::_12_0,
|
||||
Direct3D::D3D_FEATURE_LEVEL_12_1 => FeatureLevel::_12_1,
|
||||
Direct3D::D3D_FEATURE_LEVEL_12_2 => FeatureLevel::_12_2,
|
||||
_ => unreachable!(),
|
||||
fl => {
|
||||
if let Some(telemetry) = telemetry {
|
||||
(telemetry.d3d12_expose_adapter)(
|
||||
&desc,
|
||||
driver_version,
|
||||
crate::D3D12ExposeAdapterResult::UnknownFeatureLevel(fl.0),
|
||||
);
|
||||
}
|
||||
return None;
|
||||
}
|
||||
};
|
||||
|
||||
let device_name = auxil::dxgi::conv::map_adapter_name(desc.Description);
|
||||
@@ -157,10 +170,20 @@ impl super::Adapter {
|
||||
// use a version that starts with 10.x.x.x. Versions that ship from Nuget use 1.0.x.x.
|
||||
//
|
||||
// As far as we know, this is only an issue on the Nuget versions.
|
||||
if is_warp && driver_version >= [1, 0, 13, 0] && driver_version[0] < 10 {
|
||||
workarounds.avoid_shader_debug_info = true;
|
||||
if let Ok(driver_version) = driver_version {
|
||||
if is_warp && driver_version >= [1, 0, 13, 0] && driver_version[0] < 10 {
|
||||
workarounds.avoid_shader_debug_info = true;
|
||||
}
|
||||
}
|
||||
|
||||
let driver_version_string = {
|
||||
let driver_version = driver_version.unwrap_or([0, 0, 0, 0]);
|
||||
format!(
|
||||
"{}.{}.{}.{}",
|
||||
driver_version[0], driver_version[1], driver_version[2], driver_version[3]
|
||||
)
|
||||
};
|
||||
|
||||
let info = wgt::AdapterInfo {
|
||||
backend: wgt::Backend::Dx12,
|
||||
name: device_name,
|
||||
@@ -176,10 +199,7 @@ impl super::Adapter {
|
||||
wgt::DeviceType::DiscreteGpu
|
||||
},
|
||||
device_pci_bus_id: get_adapter_pci_info(desc.VendorId, desc.DeviceId),
|
||||
driver: format!(
|
||||
"{}.{}.{}.{}",
|
||||
driver_version[0], driver_version[1], driver_version[2], driver_version[3]
|
||||
),
|
||||
driver: driver_version_string,
|
||||
driver_info: String::new(),
|
||||
subgroup_min_size: features1.WaveLaneCountMin,
|
||||
subgroup_max_size: features1.WaveLaneCountMax,
|
||||
|
||||
+2
-1
@@ -2814,6 +2814,7 @@ pub struct TlasInstance {
|
||||
#[cfg(dx12)]
|
||||
pub enum D3D12ExposeAdapterResult {
|
||||
CreateDeviceError(dx12::CreateDeviceError),
|
||||
UnknownFeatureLevel(i32),
|
||||
ResourceBindingTier2Requirement,
|
||||
ShaderModel6Requirement,
|
||||
Success(dx12::FeatureLevel, dx12::ShaderModel),
|
||||
@@ -2825,7 +2826,7 @@ pub struct Telemetry {
|
||||
#[cfg(dx12)]
|
||||
pub d3d12_expose_adapter: fn(
|
||||
desc: &windows::Win32::Graphics::Dxgi::DXGI_ADAPTER_DESC2,
|
||||
driver_version: [u16; 4],
|
||||
driver_version: Result<[u16; 4], windows_core::HRESULT>,
|
||||
result: D3D12ExposeAdapterResult,
|
||||
),
|
||||
}
|
||||
Reference in new issue
Block a user