d3d12: enable parallel shader compilation
Turns out the weird errors were because of mipmapping
This commit is contained in:
parent
a3589cc794
commit
34b334fd7f
|
@ -49,8 +49,9 @@ use windows::Win32::System::Threading::{CreateEventA, ResetEvent, WaitForSingleO
|
||||||
use windows::Win32::System::WindowsProgramming::INFINITE;
|
use windows::Win32::System::WindowsProgramming::INFINITE;
|
||||||
use crate::error::FilterChainError;
|
use crate::error::FilterChainError;
|
||||||
|
|
||||||
type DxilShaderPassMeta = ShaderPassArtifact<impl CompileReflectShader<DXIL, GlslangCompilation>>;
|
use rayon::prelude::*;
|
||||||
type HlslShaderPassMeta = ShaderPassArtifact<impl CompileReflectShader<HLSL, GlslangCompilation>>;
|
type DxilShaderPassMeta = ShaderPassArtifact<impl CompileReflectShader<DXIL, GlslangCompilation> + Send>;
|
||||||
|
type HlslShaderPassMeta = ShaderPassArtifact<impl CompileReflectShader<HLSL, GlslangCompilation> + Send>;
|
||||||
|
|
||||||
pub struct FilterMutable {
|
pub struct FilterMutable {
|
||||||
pub(crate) passes_enabled: usize,
|
pub(crate) passes_enabled: usize,
|
||||||
|
@ -343,13 +344,6 @@ impl FilterChainD3D12 {
|
||||||
semantics: &ShaderSemantics,
|
semantics: &ShaderSemantics,
|
||||||
force_hlsl: bool,
|
force_hlsl: bool,
|
||||||
) -> error::Result<(ID3D12DescriptorHeap, ID3D12DescriptorHeap, Vec<FilterPass>)> {
|
) -> error::Result<(ID3D12DescriptorHeap, ID3D12DescriptorHeap, Vec<FilterPass>)> {
|
||||||
let validator: IDxcValidator = unsafe { DxcCreateInstance(&CLSID_DxcValidator)? };
|
|
||||||
|
|
||||||
let library: IDxcUtils = unsafe { DxcCreateInstance(&CLSID_DxcLibrary)? };
|
|
||||||
|
|
||||||
let compiler: IDxcCompiler = unsafe { DxcCreateInstance(&CLSID_DxcCompiler)? };
|
|
||||||
|
|
||||||
let mut filters = Vec::new();
|
|
||||||
let shader_count = passes.len();
|
let shader_count = passes.len();
|
||||||
let work_heap = D3D12DescriptorHeap::<ResourceWorkHeap>::new(
|
let work_heap = D3D12DescriptorHeap::<ResourceWorkHeap>::new(
|
||||||
device,
|
device,
|
||||||
|
@ -364,16 +358,17 @@ impl FilterChainD3D12 {
|
||||||
let (sampler_work_heaps, sampler_heap_handle) =
|
let (sampler_work_heaps, sampler_heap_handle) =
|
||||||
unsafe { sampler_work_heap.suballocate(MAX_BINDINGS_COUNT as usize) };
|
unsafe { sampler_work_heap.suballocate(MAX_BINDINGS_COUNT as usize) };
|
||||||
|
|
||||||
for (
|
let filters: Vec<error::Result<_>> = passes.into_par_iter()
|
||||||
index,
|
|
||||||
((((config, source, mut dxil), (_, _, mut hlsl)), mut texture_heap), mut sampler_heap),
|
|
||||||
) in passes
|
|
||||||
.into_iter()
|
|
||||||
.zip(hlsl_passes)
|
.zip(hlsl_passes)
|
||||||
.zip(work_heaps)
|
|
||||||
.zip(sampler_work_heaps)
|
|
||||||
.enumerate()
|
.enumerate()
|
||||||
{
|
.map(|(
|
||||||
|
index,
|
||||||
|
((config, source, mut dxil),
|
||||||
|
(_, _, mut hlsl)), )|{
|
||||||
|
let validator: IDxcValidator = unsafe { DxcCreateInstance(&CLSID_DxcValidator)? };
|
||||||
|
let library: IDxcUtils = unsafe { DxcCreateInstance(&CLSID_DxcLibrary)? };
|
||||||
|
let compiler: IDxcCompiler = unsafe { DxcCreateInstance(&CLSID_DxcCompiler)? };
|
||||||
|
|
||||||
let dxil_reflection = dxil.reflect(index, semantics)?;
|
let dxil_reflection = dxil.reflect(index, semantics)?;
|
||||||
let dxil = dxil.compile(Some(
|
let dxil = dxil.compile(Some(
|
||||||
librashader_reflect::back::dxil::ShaderModel::ShaderModel6_0,
|
librashader_reflect::back::dxil::ShaderModel::ShaderModel6_0,
|
||||||
|
@ -442,21 +437,50 @@ impl FilterChainD3D12 {
|
||||||
|
|
||||||
let uniform_bindings = reflection.meta.create_binding_map(|param| param.offset());
|
let uniform_bindings = reflection.meta.create_binding_map(|param| param.offset());
|
||||||
|
|
||||||
|
Ok((reflection,
|
||||||
|
uniform_bindings,
|
||||||
|
uniform_storage,
|
||||||
|
push_cbuffer,
|
||||||
|
ubo_cbuffer,
|
||||||
|
graphics_pipeline,
|
||||||
|
config.clone(),
|
||||||
|
source))
|
||||||
|
|
||||||
|
}).collect();
|
||||||
|
|
||||||
|
let filters: error::Result<Vec<_>> = filters.into_iter().collect();
|
||||||
|
let filters = filters?;
|
||||||
|
|
||||||
|
let filters: Vec<error::Result<FilterPass>> = filters.into_iter()
|
||||||
|
.zip(work_heaps)
|
||||||
|
.zip(sampler_work_heaps)
|
||||||
|
.map(|(((reflection,
|
||||||
|
uniform_bindings,
|
||||||
|
uniform_storage,
|
||||||
|
push_cbuffer,
|
||||||
|
ubo_cbuffer,
|
||||||
|
pipeline,
|
||||||
|
config,
|
||||||
|
source), mut texture_heap), mut sampler_heap)| {
|
||||||
|
|
||||||
let texture_heap = texture_heap.alloc_range()?;
|
let texture_heap = texture_heap.alloc_range()?;
|
||||||
let sampler_heap = sampler_heap.alloc_range()?;
|
let sampler_heap = sampler_heap.alloc_range()?;
|
||||||
filters.push(FilterPass {
|
Ok(FilterPass {
|
||||||
reflection,
|
reflection,
|
||||||
uniform_bindings,
|
uniform_bindings,
|
||||||
uniform_storage,
|
uniform_storage,
|
||||||
push_cbuffer,
|
push_cbuffer,
|
||||||
ubo_cbuffer,
|
ubo_cbuffer,
|
||||||
pipeline: graphics_pipeline,
|
pipeline,
|
||||||
config: config.clone(),
|
config,
|
||||||
texture_heap,
|
texture_heap,
|
||||||
sampler_heap,
|
sampler_heap,
|
||||||
source,
|
source,
|
||||||
})
|
})
|
||||||
}
|
})
|
||||||
|
.collect();
|
||||||
|
let filters: error::Result<Vec<_>> = filters.into_iter().collect();
|
||||||
|
let filters = filters?;
|
||||||
|
|
||||||
Ok((texture_heap_handle, sampler_heap_handle, filters))
|
Ok((texture_heap_handle, sampler_heap_handle, filters))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue