d3d11: fall back to singlethreaded shader compile if device was single threaded
This commit is contained in:
parent
dcc6280b4f
commit
07b20fecdc
2 changed files with 80 additions and 73 deletions
|
@ -31,8 +31,9 @@ use librashader_runtime::uniforms::UniformStorage;
|
|||
use rayon::prelude::*;
|
||||
use windows::Win32::Graphics::Direct3D11::{
|
||||
ID3D11Buffer, ID3D11Device, ID3D11DeviceContext, D3D11_BIND_CONSTANT_BUFFER, D3D11_BUFFER_DESC,
|
||||
D3D11_CPU_ACCESS_WRITE, D3D11_RESOURCE_MISC_FLAG, D3D11_RESOURCE_MISC_GENERATE_MIPS,
|
||||
D3D11_TEXTURE2D_DESC, D3D11_USAGE_DEFAULT, D3D11_USAGE_DYNAMIC,
|
||||
D3D11_CPU_ACCESS_WRITE, D3D11_CREATE_DEVICE_SINGLETHREADED, D3D11_RESOURCE_MISC_FLAG,
|
||||
D3D11_RESOURCE_MISC_GENERATE_MIPS, D3D11_TEXTURE2D_DESC, D3D11_USAGE_DEFAULT,
|
||||
D3D11_USAGE_DYNAMIC,
|
||||
};
|
||||
use windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
|
||||
|
@ -225,11 +226,10 @@ impl FilterChainD3D11 {
|
|||
passes: Vec<ShaderPassMeta>,
|
||||
semantics: &ShaderSemantics,
|
||||
) -> error::Result<Vec<FilterPass>> {
|
||||
// access to ID3D11Device is thread safe.
|
||||
let filters: Vec<error::Result<FilterPass>> = passes
|
||||
.into_par_iter()
|
||||
.enumerate()
|
||||
.map(|(index, (config, source, mut reflect))| {
|
||||
let device_is_singlethreaded =
|
||||
unsafe { (device.GetCreationFlags() & D3D11_CREATE_DEVICE_SINGLETHREADED.0) == 1 };
|
||||
|
||||
let builder_fn = |(index, (config, source, mut reflect)): (usize, ShaderPassMeta)| {
|
||||
let reflection = reflect.reflect(index, semantics)?;
|
||||
let hlsl = reflect.compile(None)?;
|
||||
|
||||
|
@ -300,8 +300,15 @@ impl FilterChainD3D11 {
|
|||
source,
|
||||
config,
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
};
|
||||
|
||||
let filters: Vec<error::Result<FilterPass>> = if device_is_singlethreaded {
|
||||
// D3D11Device is not thread safe
|
||||
passes.into_iter().enumerate().map(builder_fn).collect()
|
||||
} else {
|
||||
// D3D11Device is thread safe
|
||||
passes.into_par_iter().enumerate().map(builder_fn).collect()
|
||||
};
|
||||
|
||||
let filters: error::Result<Vec<FilterPass>> = filters.into_iter().collect();
|
||||
let filters = filters?;
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 39fd0bef8f7615062193b829c5f5ebfaa4a56949
|
||||
Subproject commit 9e89aafe0f6a63645445ca8302b88e4060274c72
|
Loading…
Add table
Reference in a new issue