[d3d12] remove complex DXC loading rules

This commit is contained in:
teoxoy 2024-12-02 16:16:20 +01:00 committed by Teodor Tanasoaia
parent 2aac44bb73
commit 201d9ea79f
4 changed files with 13 additions and 25 deletions

View File

@ -240,8 +240,8 @@ impl<A: hal::Api> Example<A> {
name: "example",
flags: wgt::InstanceFlags::default(),
dx12_shader_compiler: wgt::Dx12Compiler::DynamicDxc {
dxil_path: None,
dxc_path: None,
dxc_path: std::path::PathBuf::from("dxcompiler.dll"),
dxil_path: std::path::PathBuf::from("dxil.dll"),
},
gles_minor_version: wgt::Gles3MinorVersion::default(),
};

View File

@ -98,19 +98,7 @@ struct DxcLib {
}
impl DxcLib {
fn new_dynamic(
lib_path: Option<PathBuf>,
lib_name: &'static str,
) -> Result<Self, libloading::Error> {
let lib_path = if let Some(lib_path) = lib_path {
if lib_path.is_file() {
lib_path
} else {
lib_path.join(lib_name)
}
} else {
PathBuf::from(lib_name)
};
fn new_dynamic(lib_path: PathBuf) -> Result<Self, libloading::Error> {
unsafe { crate::dx12::DynLib::new(lib_path).map(|lib| Self { lib }) }
}
@ -167,13 +155,13 @@ pub(super) enum GetDynamicDXCContainerError {
}
pub(super) fn get_dynamic_dxc_container(
dxc_path: Option<PathBuf>,
dxil_path: Option<PathBuf>,
dxc_path: PathBuf,
dxil_path: PathBuf,
) -> Result<DxcContainer, GetDynamicDXCContainerError> {
let dxc = DxcLib::new_dynamic(dxc_path, "dxcompiler.dll")
let dxc = DxcLib::new_dynamic(dxc_path)
.map_err(|e| GetDynamicDXCContainerError::FailedToLoad("dxcompiler.dll", e))?;
let dxil = DxcLib::new_dynamic(dxil_path, "dxil.dll")
let dxil = DxcLib::new_dynamic(dxil_path)
.map_err(|e| GetDynamicDXCContainerError::FailedToLoad("dxil.dll", e))?;
let compiler = dxc.create_instance::<Dxc::IDxcCompiler3>()?;

View File

@ -7432,10 +7432,10 @@ pub enum Dx12Compiler {
///
/// It also requires WDDM 2.1 (Windows 10 version 1607).
DynamicDxc {
/// Path to the `dxil.dll` file, or path to the directory containing `dxil.dll` file. Passing `None` will use standard platform specific dll loading rules.
dxil_path: Option<PathBuf>,
/// Path to the `dxcompiler.dll` file, or path to the directory containing `dxcompiler.dll` file. Passing `None` will use standard platform specific dll loading rules.
dxc_path: Option<PathBuf>,
/// Path to `dxcompiler.dll`.
dxc_path: PathBuf,
/// Path to `dxil.dll`.
dxil_path: PathBuf,
},
/// The statically-linked variant of Dxc.
/// The `static-dxc` feature is required to use this.

View File

@ -108,8 +108,8 @@ pub fn dx12_shader_compiler_from_env() -> Option<wgt::Dx12Compiler> {
.as_deref()
{
Ok("dxc") => wgt::Dx12Compiler::DynamicDxc {
dxil_path: None,
dxc_path: None,
dxc_path: std::path::PathBuf::from("dxcompiler.dll"),
dxil_path: std::path::PathBuf::from("dxil.dll"),
},
#[cfg(feature = "static-dxc")]
Ok("static-dxc") => wgt::Dx12Compiler::StaticDxc,