// Create DeviceFactory first so we know which debug path to use let device_factory =
DeviceFactory::new(&lib_main, desc.backend_options.dx12.agility_sdk.as_ref())?;
match hr {
Err(err) => log::warn!("Unable to check for tearing support: {err}"),
Ok(()) => supports_allow_tearing = true,
}
}
// Initialize the shader compiler let compiler_container = match desc.backend_options.dx12.shader_compiler.clone() {
wgt::Dx12Compiler::DynamicDxc { dxc_path } => {
CompilerContainer::new_dynamic_dxc(dxc_path.into()).map_err(|e| { crate::InstanceError::with_source(String::from("Failed to load dynamic DXC"), e)
})?
}
wgt::Dx12Compiler::StaticDxc => CompilerContainer::new_static_dxc().map_err(|e| { crate::InstanceError::with_source(String::from("Failed to load static DXC"), e)
})?,
wgt::Dx12Compiler::Fxc => CompilerContainer::new_fxc().map_err(|e| { crate::InstanceError::with_source(String::from("Failed to load FXC"), e)
})?,
wgt::Dx12Compiler::Auto => { if cfg!(feature = "static-dxc") { // Prefer static DXC if its compiled in
CompilerContainer::new_static_dxc().map_err(|e| { crate::InstanceError::with_source(
String::from("Failed to load static DXC"),
e,
)
})?
} else { // Try to load dynamic DXC let dynamic = CompilerContainer::new_dynamic_dxc("dxcompiler.dll".into()); match dynamic {
Ok(v) => v,
Err(super::shader_compilation::GetContainerError::FailedToLoad(..)) => { // If it can't be found load FXC
CompilerContainer::new_fxc().map_err(|e| { crate::InstanceError::with_source(
String::from("Failed to load FXC"),
e,
)
})?
}
Err(e) => { // If another error occurs when loading static DXC return that error return Err(crate::InstanceError::with_source(
String::from("Failed to load dynamic DXC"),
e,
));
}
}
}
}
};
match compiler_container {
CompilerContainer::DynamicDxc(..) => {
log::debug!("Using dynamic DXC for shader compilation")
}
CompilerContainer::StaticDxc(..) => {
log::debug!("Using static DXC for shader compilation")
}
CompilerContainer::Fxc(..) => {
log::debug!("Using FXC for shader compilation")
}
}
Ok(Self { // The call to create_factory will only succeed if we get a factory4, so this is safe.
factory,
factory_media,
library: Arc::new(lib_main),
device_factory: Arc::new(device_factory),
dcomp_lib: Arc::new(DCompLib::new()),
presentation_system: desc.backend_options.dx12.presentation_system,
_lib_dxgi: lib_dxgi,
supports_allow_tearing,
flags: desc.flags,
memory_budget_thresholds: desc.memory_budget_thresholds,
compiler_container: Arc::new(compiler_container),
options: desc.backend_options.dx12.clone(),
telemetry: desc.telemetry,
})
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.