mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-21 22:33:49 +00:00
[d3d12] handle absence of Windows SDK (#6262)
This commit is contained in:
parent
c2e0ad293f
commit
ff52b86331
@ -138,7 +138,7 @@ pub fn create_factory(
|
|||||||
// The `DXGI_CREATE_FACTORY_DEBUG` flag is only allowed to be passed to
|
// The `DXGI_CREATE_FACTORY_DEBUG` flag is only allowed to be passed to
|
||||||
// `CreateDXGIFactory2` if the debug interface is actually available. So
|
// `CreateDXGIFactory2` if the debug interface is actually available. So
|
||||||
// we check for whether it exists first.
|
// we check for whether it exists first.
|
||||||
if lib_dxgi.debug_interface1().is_ok() {
|
if let Ok(Some(_)) = lib_dxgi.debug_interface1() {
|
||||||
factory_flags |= Dxgi::DXGI_CREATE_FACTORY_DEBUG;
|
factory_flags |= Dxgi::DXGI_CREATE_FACTORY_DEBUG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ impl crate::Instance for super::Instance {
|
|||||||
.intersects(wgt::InstanceFlags::VALIDATION | wgt::InstanceFlags::GPU_BASED_VALIDATION)
|
.intersects(wgt::InstanceFlags::VALIDATION | wgt::InstanceFlags::GPU_BASED_VALIDATION)
|
||||||
{
|
{
|
||||||
// Enable debug layer
|
// Enable debug layer
|
||||||
if let Ok(debug_controller) = lib_main.debug_interface() {
|
if let Ok(Some(debug_controller)) = lib_main.debug_interface() {
|
||||||
if desc.flags.intersects(wgt::InstanceFlags::VALIDATION) {
|
if desc.flags.intersects(wgt::InstanceFlags::VALIDATION) {
|
||||||
unsafe { debug_controller.EnableDebugLayer() }
|
unsafe { debug_controller.EnableDebugLayer() }
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@ impl D3D12Lib {
|
|||||||
blob.ok_or(crate::DeviceError::Unexpected)
|
blob.ok_or(crate::DeviceError::Unexpected)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn debug_interface(&self) -> Result<Direct3D12::ID3D12Debug, crate::DeviceError> {
|
fn debug_interface(&self) -> Result<Option<Direct3D12::ID3D12Debug>, crate::DeviceError> {
|
||||||
// Calls windows::Win32::Graphics::Direct3D12::D3D12GetDebugInterface on d3d12.dll
|
// Calls windows::Win32::Graphics::Direct3D12::D3D12GetDebugInterface on d3d12.dll
|
||||||
type Fun = extern "system" fn(
|
type Fun = extern "system" fn(
|
||||||
riid: *const windows_core::GUID,
|
riid: *const windows_core::GUID,
|
||||||
@ -200,11 +200,18 @@ impl D3D12Lib {
|
|||||||
|
|
||||||
let mut result__ = None;
|
let mut result__ = None;
|
||||||
|
|
||||||
(func)(&Direct3D12::ID3D12Debug::IID, <*mut _>::cast(&mut result__))
|
let res = (func)(&Direct3D12::ID3D12Debug::IID, <*mut _>::cast(&mut result__)).ok();
|
||||||
.ok()
|
|
||||||
.into_device_result("GetDebugInterface")?;
|
|
||||||
|
|
||||||
result__.ok_or(crate::DeviceError::Unexpected)
|
if let Err(ref err) = res {
|
||||||
|
match err.code() {
|
||||||
|
Dxgi::DXGI_ERROR_SDK_COMPONENT_MISSING => return Ok(None),
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
res.into_device_result("GetDebugInterface")?;
|
||||||
|
|
||||||
|
result__.ok_or(crate::DeviceError::Unexpected).map(Some)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,7 +226,7 @@ impl DxgiLib {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Will error with crate::DeviceError::Unexpected if DXGI 1.3 is not available.
|
/// Will error with crate::DeviceError::Unexpected if DXGI 1.3 is not available.
|
||||||
pub fn debug_interface1(&self) -> Result<Dxgi::IDXGIInfoQueue, crate::DeviceError> {
|
pub fn debug_interface1(&self) -> Result<Option<Dxgi::IDXGIInfoQueue>, crate::DeviceError> {
|
||||||
// Calls windows::Win32::Graphics::Dxgi::DXGIGetDebugInterface1 on dxgi.dll
|
// Calls windows::Win32::Graphics::Dxgi::DXGIGetDebugInterface1 on dxgi.dll
|
||||||
type Fun = extern "system" fn(
|
type Fun = extern "system" fn(
|
||||||
flags: u32,
|
flags: u32,
|
||||||
@ -230,11 +237,18 @@ impl DxgiLib {
|
|||||||
|
|
||||||
let mut result__ = None;
|
let mut result__ = None;
|
||||||
|
|
||||||
(func)(0, &Dxgi::IDXGIInfoQueue::IID, <*mut _>::cast(&mut result__))
|
let res = (func)(0, &Dxgi::IDXGIInfoQueue::IID, <*mut _>::cast(&mut result__)).ok();
|
||||||
.ok()
|
|
||||||
.into_device_result("debug_interface1")?;
|
|
||||||
|
|
||||||
result__.ok_or(crate::DeviceError::Unexpected)
|
if let Err(ref err) = res {
|
||||||
|
match err.code() {
|
||||||
|
Dxgi::DXGI_ERROR_SDK_COMPONENT_MISSING => return Ok(None),
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
res.into_device_result("debug_interface1")?;
|
||||||
|
|
||||||
|
result__.ok_or(crate::DeviceError::Unexpected).map(Some)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Will error with crate::DeviceError::Unexpected if DXGI 1.4 is not available.
|
/// Will error with crate::DeviceError::Unexpected if DXGI 1.4 is not available.
|
||||||
|
Loading…
Reference in New Issue
Block a user