DXC on DX12 in CI (#4571)

This commit is contained in:
Connor Fitzgerald authored and GitHub committed 2023-10-26 04:01:38 -04:00
1 parent a4b53169c6
commit ca7ac86ccd
13 files changed
+59 -27

No files matched your search

+4 -4
View File
@@ -1,6 +1,6 @@
use crate::{
auxil::{self, dxgi::result::HResult as _},
dx12::SurfaceTarget,
dx12::{shader_compilation, SurfaceTarget},
};
use std::{mem, ptr, sync::Arc, thread};
use winapi::{
@@ -50,7 +50,7 @@ impl super::Adapter {
adapter: d3d12::DxgiAdapter,
library: &Arc<d3d12::D3D12Lib>,
instance_flags: wgt::InstanceFlags,
dx12_shader_compiler: &wgt::Dx12Compiler,
dxc_container: Option<Arc<shader_compilation::DxcContainer>>,
) -> Option<crate::ExposedAdapter<super::Api>> {
// Create the device so that we can get the capabilities.
let device = {
@@ -305,7 +305,7 @@ impl super::Adapter {
private_caps,
presentation_timer,
workarounds,
dx12_shader_compiler: dx12_shader_compiler.clone(),
dxc_container,
},
info,
features,
@@ -421,7 +421,7 @@ impl crate::Adapter<super::Api> for super::Adapter {
limits,
self.private_caps,
&self.library,
self.dx12_shader_compiler.clone(),
self.dxc_container.clone(),
)?;
Ok(crate::OpenDevice {
device,
+5 -10
View File
@@ -1,4 +1,7 @@
use crate::auxil::{self, dxgi::result::HResult as _};
use crate::{
auxil::{self, dxgi::result::HResult as _},
dx12::shader_compilation,
};
use super::{conv, descriptor, view};
use parking_lot::Mutex;
@@ -19,7 +22,7 @@ impl super::Device {
limits: &wgt::Limits,
private_caps: super::PrivateCapabilities,
library: &Arc<d3d12::D3D12Lib>,
dx12_shader_compiler: wgt::Dx12Compiler,
dxc_container: Option<Arc<shader_compilation::DxcContainer>>,
) -> Result<Self, crate::DeviceError> {
let mem_allocator = if private_caps.suballocation_supported {
super::suballocation::create_allocator_wrapper(&raw)?
@@ -27,14 +30,6 @@ impl super::Device {
None
};
let dxc_container = match dx12_shader_compiler {
wgt::Dx12Compiler::Dxc {
dxil_path,
dxc_path,
} => super::shader_compilation::get_dxc_container(dxc_path, dxil_path)?,
wgt::Dx12Compiler::Fxc => None,
};
let mut idle_fence = d3d12::Fence::null();
let hr = unsafe {
profiling::scope!("ID3D12Device::CreateFence");
+23 -2
View File
@@ -72,6 +72,27 @@ impl crate::Instance<super::Api> for super::Instance {
}
}
// Initialize DXC shader compiler
let dxc_container = match desc.dx12_shader_compiler.clone() {
wgt::Dx12Compiler::Dxc {
dxil_path,
dxc_path,
} => {
let container = super::shader_compilation::get_dxc_container(dxc_path, dxil_path)
.map_err(|e| {
crate::InstanceError::with_source(String::from("Failed to load DXC"), e)
})?;
container.map(Arc::new)
}
wgt::Dx12Compiler::Fxc => None,
};
match dxc_container {
Some(_) => log::debug!("Using DXC for shader compilation"),
None => 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,
@@ -80,7 +101,7 @@ impl crate::Instance<super::Api> for super::Instance {
_lib_dxgi: lib_dxgi,
supports_allow_tearing,
flags: desc.flags,
dx12_shader_compiler: desc.dx12_shader_compiler.clone(),
dxc_container,
})
}
@@ -112,7 +133,7 @@ impl crate::Instance<super::Api> for super::Instance {
adapters
.into_iter()
.filter_map(|raw| {
super::Adapter::expose(raw, &self.library, self.flags, &self.dx12_shader_compiler)
super::Adapter::expose(raw, &self.library, self.flags, self.dxc_container.clone())
})
.collect()
}
+3 -3
View File
@@ -95,7 +95,7 @@ pub struct Instance {
supports_allow_tearing: bool,
_lib_dxgi: d3d12::DxgiLib,
flags: wgt::InstanceFlags,
dx12_shader_compiler: wgt::Dx12Compiler,
dxc_container: Option<Arc<shader_compilation::DxcContainer>>,
}
impl Instance {
@@ -211,7 +211,7 @@ pub struct Adapter {
//Note: this isn't used right now, but we'll need it later.
#[allow(unused)]
workarounds: Workarounds,
dx12_shader_compiler: wgt::Dx12Compiler,
dxc_container: Option<Arc<shader_compilation::DxcContainer>>,
}
unsafe impl Send for Adapter {}
@@ -253,7 +253,7 @@ pub struct Device {
render_doc: crate::auxil::renderdoc::RenderDoc,
null_rtv_handle: descriptor::Handle,
mem_allocator: Option<Mutex<suballocation::GpuAllocatorWrapper>>,
dxc_container: Option<shader_compilation::DxcContainer>,
dxc_container: Option<Arc<shader_compilation::DxcContainer>>,
}
unsafe impl Send for Device {}
+2 -2
View File
@@ -99,7 +99,7 @@ mod dxc {
let dxil = match hassle_rs::Dxil::new(dxil_path) {
Ok(dxil) => dxil,
Err(e) => {
log::warn!("Failed to load dxil.dll. Defaulting to Fxc instead: {}", e);
log::warn!("Failed to load dxil.dll. Defaulting to DXC instead: {}", e);
return Ok(None);
}
};
@@ -111,7 +111,7 @@ mod dxc {
Ok(dxc) => dxc,
Err(e) => {
log::warn!(
"Failed to load dxcompiler.dll. Defaulting to Fxc instead: {}",
"Failed to load dxcompiler.dll. Defaulting to FXC instead: {}",
e
);
return Ok(None);