mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-23 23:34:29 +00:00
DXC on DX12 in CI (#4571)
This commit is contained in:
parent
a4b53169c6
commit
ca7ac86ccd
5
.github/workflows/ci.yml
vendored
5
.github/workflows/ci.yml
vendored
@ -10,6 +10,7 @@ on:
|
||||
env:
|
||||
CARGO_INCREMENTAL: false
|
||||
CARGO_TERM_COLOR: always
|
||||
WGPU_DX12_COMPILER: dxc
|
||||
RUST_LOG: info
|
||||
RUST_BACKTRACE: full
|
||||
# This is the MSRV used by `wgpu` itself and all surrounding infrastructure.
|
||||
@ -353,6 +354,10 @@ jobs:
|
||||
. -> target
|
||||
xtask -> xtask/target
|
||||
|
||||
- name: (windows) install dxc
|
||||
if: matrix.os == 'windows-2022'
|
||||
uses: napokue/setup-dxc@v1.1.0
|
||||
|
||||
- name: (windows) install warp
|
||||
if: matrix.os == 'windows-2022'
|
||||
shell: bash
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 8.3 KiB |
@ -372,8 +372,8 @@ static TEST: wgpu_example::framework::ExampleTestParams =
|
||||
comparisons: &[
|
||||
wgpu_test::ComparisonType::Mean(0.05),
|
||||
wgpu_test::ComparisonType::Percentile {
|
||||
percentile: 0.95,
|
||||
threshold: 0.05,
|
||||
percentile: 0.99,
|
||||
threshold: 0.19,
|
||||
},
|
||||
],
|
||||
_phantom: std::marker::PhantomData::<Example>,
|
||||
|
@ -156,7 +156,7 @@ async fn setup<E: Example>(title: &str) -> Setup {
|
||||
|
||||
log::info!("Initializing the surface...");
|
||||
|
||||
let backends = wgpu::util::backend_bits_from_env().unwrap_or_else(wgpu::Backends::all);
|
||||
let backends = wgpu::util::backend_bits_from_env().unwrap_or_default();
|
||||
let dx12_shader_compiler = wgpu::util::dx12_shader_compiler_from_env().unwrap_or_default();
|
||||
let gles_minor_version = wgpu::util::gles_minor_version_from_env().unwrap_or_default();
|
||||
|
||||
|
@ -178,7 +178,7 @@ impl Queries {
|
||||
#[cfg_attr(test, allow(unused))]
|
||||
async fn run() {
|
||||
// Instantiates instance of wgpu
|
||||
let backends = wgpu::util::backend_bits_from_env().unwrap_or_else(wgpu::Backends::all);
|
||||
let backends = wgpu::util::backend_bits_from_env().unwrap_or_default();
|
||||
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
|
||||
backends,
|
||||
flags: wgpu::InstanceFlags::from_build_config().with_env(),
|
||||
|
@ -3,7 +3,7 @@
|
||||
async fn get() -> wgpu::Adapter {
|
||||
let adapter = {
|
||||
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
|
||||
backends: wgpu::util::backend_bits_from_env().unwrap_or_else(wgpu::Backends::all),
|
||||
backends: wgpu::util::backend_bits_from_env().unwrap_or_default(),
|
||||
..Default::default()
|
||||
});
|
||||
instance
|
||||
|
@ -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,
|
||||
|
@ -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");
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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 {}
|
||||
|
@ -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);
|
||||
|
@ -17,7 +17,12 @@ pub struct GpuReport {
|
||||
|
||||
impl GpuReport {
|
||||
pub fn generate() -> Self {
|
||||
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor::default());
|
||||
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
|
||||
backends: wgpu::util::backend_bits_from_env().unwrap_or_default(),
|
||||
flags: wgpu::InstanceFlags::debugging().with_env(),
|
||||
dx12_shader_compiler: wgpu::util::dx12_shader_compiler_from_env().unwrap_or_default(),
|
||||
gles_minor_version: wgpu::util::gles_minor_version_from_env().unwrap_or_default(),
|
||||
});
|
||||
let adapters = instance.enumerate_adapters(wgpu::Backends::all());
|
||||
|
||||
let mut devices = Vec::with_capacity(adapters.len());
|
||||
|
@ -177,6 +177,12 @@ bitflags::bitflags! {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Backends {
|
||||
fn default() -> Self {
|
||||
Self::all()
|
||||
}
|
||||
}
|
||||
|
||||
impl_bitflags!(Backends);
|
||||
|
||||
impl From<Backend> for Backends {
|
||||
|
Loading…
Reference in New Issue
Block a user