diff --git a/wgpu-hal/examples/ray-traced-triangle/main.rs b/wgpu-hal/examples/ray-traced-triangle/main.rs index 6754dc36a..f24f0c4c4 100644 --- a/wgpu-hal/examples/ray-traced-triangle/main.rs +++ b/wgpu-hal/examples/ray-traced-triangle/main.rs @@ -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(), }; diff --git a/wgpu-hal/src/dx12/shader_compilation.rs b/wgpu-hal/src/dx12/shader_compilation.rs index 53e44e6d3..973962701 100644 --- a/wgpu-hal/src/dx12/shader_compilation.rs +++ b/wgpu-hal/src/dx12/shader_compilation.rs @@ -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>()?; diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 546a3fde0..ec05e86e4 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -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. diff --git a/wgpu/src/util/init.rs b/wgpu/src/util/init.rs index 2419f4be9..87f787bcb 100644 --- a/wgpu/src/util/init.rs +++ b/wgpu/src/util/init.rs @@ -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,