rt: fix TAIT usages
This commit is contained in:
parent
3735659604
commit
59cc3deb09
|
@ -1,7 +1,7 @@
|
|||
use crate::texture::{D3D11InputView, InputTexture, LutTexture};
|
||||
use librashader_common::{ImageFormat, Size, Viewport};
|
||||
|
||||
use librashader_presets::{ShaderPreset, TextureConfig};
|
||||
use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig};
|
||||
use librashader_reflect::back::targets::HLSL;
|
||||
use librashader_reflect::back::{CompileReflectShader, CompileShader};
|
||||
use librashader_reflect::front::GlslangCompilation;
|
||||
|
@ -45,9 +45,6 @@ pub struct FilterMutable {
|
|||
pub(crate) parameters: FxHashMap<String, f32>,
|
||||
}
|
||||
|
||||
type ShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<HLSL, GlslangCompilation> + Send>;
|
||||
|
||||
/// A Direct3D 11 filter chain.
|
||||
pub struct FilterChainD3D11 {
|
||||
pub(crate) common: FilterCommon,
|
||||
|
@ -75,6 +72,24 @@ pub(crate) struct FilterCommon {
|
|||
pub(crate) draw_quad: DrawQuad,
|
||||
}
|
||||
|
||||
type ShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<HLSL, GlslangCompilation> + Send>;
|
||||
fn compile_passes(
|
||||
shaders: Vec<ShaderPassConfig>,
|
||||
textures: &[TextureConfig],
|
||||
disable_cache: bool,
|
||||
) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> {
|
||||
let (passes, semantics) = if !disable_cache {
|
||||
HLSL::compile_preset_passes::<CachedCompilation<GlslangCompilation>, FilterChainError>(
|
||||
shaders, &textures,
|
||||
)?
|
||||
} else {
|
||||
HLSL::compile_preset_passes::<GlslangCompilation, FilterChainError>(shaders, &textures)?
|
||||
};
|
||||
|
||||
Ok((passes, semantics))
|
||||
}
|
||||
|
||||
impl FilterChainD3D11 {
|
||||
/// Load the shader preset at the given path into a filter chain.
|
||||
pub unsafe fn load_from_path(
|
||||
|
@ -121,17 +136,7 @@ impl FilterChainD3D11 {
|
|||
) -> error::Result<FilterChainD3D11> {
|
||||
let disable_cache = options.map_or(false, |o| o.disable_cache);
|
||||
|
||||
let (passes, semantics) = if !disable_cache {
|
||||
HLSL::compile_preset_passes::<CachedCompilation<GlslangCompilation>, FilterChainError>(
|
||||
preset.shaders,
|
||||
&preset.textures,
|
||||
)?
|
||||
} else {
|
||||
HLSL::compile_preset_passes::<GlslangCompilation, FilterChainError>(
|
||||
preset.shaders,
|
||||
&preset.textures,
|
||||
)?
|
||||
};
|
||||
let (passes, semantics) = compile_passes(preset.shaders, &preset.textures, disable_cache)?;
|
||||
|
||||
let samplers = SamplerSet::new(device)?;
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ use crate::samplers::SamplerSet;
|
|||
use crate::texture::{D3D12InputImage, D3D12OutputView, InputTexture, OutputDescriptor};
|
||||
use crate::{error, util};
|
||||
use librashader_common::{ImageFormat, Size, Viewport};
|
||||
use librashader_presets::{ShaderPreset, TextureConfig};
|
||||
use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig};
|
||||
use librashader_reflect::back::targets::{DXIL, HLSL};
|
||||
use librashader_reflect::back::{CompileReflectShader, CompileShader};
|
||||
use librashader_reflect::front::GlslangCompilation;
|
||||
|
@ -54,11 +54,6 @@ use rayon::prelude::*;
|
|||
|
||||
const MIPMAP_RESERVED_WORKHEAP_DESCRIPTORS: usize = 4096;
|
||||
|
||||
type DxilShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<DXIL, GlslangCompilation> + Send>;
|
||||
type HlslShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<HLSL, GlslangCompilation> + Send>;
|
||||
|
||||
pub struct FilterMutable {
|
||||
pub(crate) passes_enabled: usize,
|
||||
pub(crate) parameters: FxHashMap<String, f32>,
|
||||
|
@ -148,6 +143,41 @@ impl Drop for FrameResiduals {
|
|||
}
|
||||
}
|
||||
|
||||
type DxilShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<DXIL, GlslangCompilation> + Send>;
|
||||
fn compile_passes_dxil(
|
||||
shaders: Vec<ShaderPassConfig>,
|
||||
textures: &[TextureConfig],
|
||||
disable_cache: bool,
|
||||
) -> Result<(Vec<DxilShaderPassMeta>, ShaderSemantics), FilterChainError> {
|
||||
let (passes, semantics) = if !disable_cache {
|
||||
DXIL::compile_preset_passes::<CachedCompilation<GlslangCompilation>, FilterChainError>(
|
||||
shaders, &textures,
|
||||
)?
|
||||
} else {
|
||||
DXIL::compile_preset_passes::<GlslangCompilation, FilterChainError>(shaders, &textures)?
|
||||
};
|
||||
|
||||
Ok((passes, semantics))
|
||||
}
|
||||
type HlslShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<HLSL, GlslangCompilation> + Send>;
|
||||
fn compile_passes_hlsl(
|
||||
shaders: Vec<ShaderPassConfig>,
|
||||
textures: &[TextureConfig],
|
||||
disable_cache: bool,
|
||||
) -> Result<(Vec<HlslShaderPassMeta>, ShaderSemantics), FilterChainError> {
|
||||
let (passes, semantics) = if !disable_cache {
|
||||
HLSL::compile_preset_passes::<CachedCompilation<GlslangCompilation>, FilterChainError>(
|
||||
shaders, &textures,
|
||||
)?
|
||||
} else {
|
||||
HLSL::compile_preset_passes::<GlslangCompilation, FilterChainError>(shaders, &textures)?
|
||||
};
|
||||
|
||||
Ok((passes, semantics))
|
||||
}
|
||||
|
||||
impl FilterChainD3D12 {
|
||||
/// Load the shader preset at the given path into a filter chain.
|
||||
pub unsafe fn load_from_path(
|
||||
|
@ -219,29 +249,8 @@ impl FilterChainD3D12 {
|
|||
let shader_copy = preset.shaders.clone();
|
||||
let disable_cache = options.map_or(false, |o| o.disable_cache);
|
||||
|
||||
let (passes, semantics) = if !disable_cache {
|
||||
DXIL::compile_preset_passes::<CachedCompilation<GlslangCompilation>, FilterChainError>(
|
||||
preset.shaders,
|
||||
&preset.textures,
|
||||
)?
|
||||
} else {
|
||||
DXIL::compile_preset_passes::<GlslangCompilation, FilterChainError>(
|
||||
preset.shaders,
|
||||
&preset.textures,
|
||||
)?
|
||||
};
|
||||
|
||||
let (hlsl_passes, _) = if !disable_cache {
|
||||
HLSL::compile_preset_passes::<CachedCompilation<GlslangCompilation>, FilterChainError>(
|
||||
shader_copy,
|
||||
&preset.textures,
|
||||
)?
|
||||
} else {
|
||||
HLSL::compile_preset_passes::<GlslangCompilation, FilterChainError>(
|
||||
shader_copy,
|
||||
&preset.textures,
|
||||
)?
|
||||
};
|
||||
let (passes, semantics) = compile_passes_dxil(preset.shaders, &preset.textures, disable_cache)?;
|
||||
let (hlsl_passes, _) = compile_passes_hlsl(shader_copy, &preset.textures, disable_cache)?;
|
||||
|
||||
let samplers = SamplerSet::new(device)?;
|
||||
let mipmap_gen = D3D12MipmapGen::new(device, false)?;
|
||||
|
@ -368,7 +377,7 @@ impl FilterChainD3D12 {
|
|||
texture.filter_mode,
|
||||
texture.wrap_mode,
|
||||
texture.mipmap,
|
||||
gc
|
||||
gc,
|
||||
)?;
|
||||
luts.insert(index, texture);
|
||||
}
|
||||
|
@ -424,22 +433,32 @@ impl FilterChainD3D12 {
|
|||
let (sampler_work_heaps, _, sampler_heap_handle) =
|
||||
unsafe { sampler_work_heap.suballocate(MAX_BINDINGS_COUNT as usize, 0) };
|
||||
|
||||
let filters: Vec<error::Result<_>> = passes.into_par_iter()
|
||||
let filters: Vec<error::Result<_>> = passes
|
||||
.into_par_iter()
|
||||
.zip(hlsl_passes)
|
||||
.zip(work_heaps)
|
||||
.zip(sampler_work_heaps)
|
||||
.enumerate()
|
||||
.map_init(
|
||||
|| {
|
||||
let validator: IDxcValidator = unsafe { DxcCreateInstance(&CLSID_DxcValidator)? };
|
||||
let validator: IDxcValidator =
|
||||
unsafe { DxcCreateInstance(&CLSID_DxcValidator)? };
|
||||
let library: IDxcUtils = unsafe { DxcCreateInstance(&CLSID_DxcLibrary)? };
|
||||
let compiler: IDxcCompiler = unsafe { DxcCreateInstance(&CLSID_DxcCompiler)? };
|
||||
Ok::<_, FilterChainError>((validator, library, compiler))
|
||||
},
|
||||
|dxc, (index, ((((config, source, mut dxil),
|
||||
(_, _, mut hlsl)), mut texture_heap), mut sampler_heap))| {
|
||||
|dxc,
|
||||
(
|
||||
index,
|
||||
(
|
||||
(((config, source, mut dxil), (_, _, mut hlsl)), mut texture_heap),
|
||||
mut sampler_heap,
|
||||
),
|
||||
)| {
|
||||
let Ok((validator, library, compiler)) = dxc else {
|
||||
return Err(FilterChainError::Direct3DOperationError("Could not initialize DXC for thread"));
|
||||
return Err(FilterChainError::Direct3DOperationError(
|
||||
"Could not initialize DXC for thread",
|
||||
));
|
||||
};
|
||||
|
||||
let dxil_reflection = dxil.reflect(index, semantics)?;
|
||||
|
@ -453,8 +472,8 @@ impl FilterChainD3D12 {
|
|||
source.format
|
||||
} else {
|
||||
ImageFormat::R8G8B8A8Unorm
|
||||
}.into();
|
||||
|
||||
}
|
||||
.into();
|
||||
|
||||
// incredibly cursed.
|
||||
let (reflection, graphics_pipeline) = if !force_hlsl &&
|
||||
|
@ -494,11 +513,11 @@ impl FilterChainD3D12 {
|
|||
|
||||
let uniform_storage = UniformStorage::new_with_storage(
|
||||
RawD3D12Buffer::new(D3D12Buffer::new(device, ubo_size)?)?,
|
||||
RawD3D12Buffer::new(D3D12Buffer::new(device, push_size)?)?
|
||||
RawD3D12Buffer::new(D3D12Buffer::new(device, push_size)?)?,
|
||||
);
|
||||
|
||||
|
||||
let uniform_bindings = reflection.meta.create_binding_map(|param| param.offset());
|
||||
let uniform_bindings =
|
||||
reflection.meta.create_binding_map(|param| param.offset());
|
||||
|
||||
let texture_heap = texture_heap.alloc_range()?;
|
||||
let sampler_heap = sampler_heap.alloc_range()?;
|
||||
|
@ -513,8 +532,9 @@ impl FilterChainD3D12 {
|
|||
sampler_heap,
|
||||
source,
|
||||
})
|
||||
|
||||
}).collect();
|
||||
},
|
||||
)
|
||||
.collect();
|
||||
|
||||
let filters: error::Result<Vec<_>> = filters.into_iter().collect();
|
||||
let filters = filters?;
|
||||
|
|
|
@ -12,7 +12,7 @@ use crate::{error, GLImage};
|
|||
use gl::types::GLuint;
|
||||
use librashader_common::Viewport;
|
||||
|
||||
use librashader_presets::ShaderPreset;
|
||||
use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig};
|
||||
use librashader_reflect::back::cross::GlslVersion;
|
||||
use librashader_reflect::back::targets::GLSL;
|
||||
use librashader_reflect::back::{CompileReflectShader, CompileShader};
|
||||
|
@ -98,6 +98,21 @@ impl<T: GLInterface> FilterChainImpl<T> {
|
|||
}
|
||||
|
||||
type ShaderPassMeta = ShaderPassArtifact<impl CompileReflectShader<GLSL, GlslangCompilation>>;
|
||||
fn compile_passes(
|
||||
shaders: Vec<ShaderPassConfig>,
|
||||
textures: &[TextureConfig],
|
||||
disable_cache: bool,
|
||||
) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> {
|
||||
let (passes, semantics) = if !disable_cache {
|
||||
GLSL::compile_preset_passes::<CachedCompilation<GlslangCompilation>, FilterChainError>(
|
||||
shaders, &textures,
|
||||
)?
|
||||
} else {
|
||||
GLSL::compile_preset_passes::<GlslangCompilation, FilterChainError>(shaders, &textures)?
|
||||
};
|
||||
|
||||
Ok((passes, semantics))
|
||||
}
|
||||
|
||||
impl<T: GLInterface> FilterChainImpl<T> {
|
||||
/// Load a filter chain from a pre-parsed `ShaderPreset`.
|
||||
|
@ -106,19 +121,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
|
|||
options: Option<&FilterChainOptionsGL>,
|
||||
) -> error::Result<Self> {
|
||||
let disable_cache = options.map_or(false, |o| o.disable_cache);
|
||||
|
||||
let (passes, semantics) = if !disable_cache {
|
||||
GLSL::compile_preset_passes::<CachedCompilation<GlslangCompilation>, FilterChainError>(
|
||||
preset.shaders,
|
||||
&preset.textures,
|
||||
)?
|
||||
} else {
|
||||
GLSL::compile_preset_passes::<GlslangCompilation, FilterChainError>(
|
||||
preset.shaders,
|
||||
&preset.textures,
|
||||
)?
|
||||
};
|
||||
|
||||
let (passes, semantics) = compile_passes(preset.shaders, &preset.textures, disable_cache)?;
|
||||
let version = options.map_or_else(gl_get_version, |o| gl_u16_to_version(o.glsl_version));
|
||||
|
||||
// initialize passes
|
||||
|
|
|
@ -14,7 +14,7 @@ use ash::vk;
|
|||
use librashader_common::{ImageFormat, Size, Viewport};
|
||||
|
||||
use gpu_allocator::vulkan::Allocator;
|
||||
use librashader_presets::{ShaderPreset, TextureConfig};
|
||||
use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig};
|
||||
use librashader_reflect::back::targets::SPIRV;
|
||||
use librashader_reflect::back::{CompileReflectShader, CompileShader};
|
||||
use librashader_reflect::front::GlslangCompilation;
|
||||
|
@ -46,9 +46,6 @@ pub struct VulkanObjects {
|
|||
// pub(crate) memory_properties: vk::PhysicalDeviceMemoryProperties,
|
||||
}
|
||||
|
||||
type ShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<SPIRV, GlslangCompilation> + Send>;
|
||||
|
||||
/// A collection of handles needed to access the Vulkan instance.
|
||||
#[derive(Clone)]
|
||||
pub struct VulkanInstance {
|
||||
|
@ -208,6 +205,24 @@ impl Drop for FrameResiduals {
|
|||
}
|
||||
}
|
||||
|
||||
type ShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<SPIRV, GlslangCompilation> + Send>;
|
||||
fn compile_passes(
|
||||
shaders: Vec<ShaderPassConfig>,
|
||||
textures: &[TextureConfig],
|
||||
disable_cache: bool,
|
||||
) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> {
|
||||
let (passes, semantics) = if !disable_cache {
|
||||
SPIRV::compile_preset_passes::<CachedCompilation<GlslangCompilation>, FilterChainError>(
|
||||
shaders, &textures,
|
||||
)?
|
||||
} else {
|
||||
SPIRV::compile_preset_passes::<GlslangCompilation, FilterChainError>(shaders, &textures)?
|
||||
};
|
||||
|
||||
Ok((passes, semantics))
|
||||
}
|
||||
|
||||
impl FilterChainVulkan {
|
||||
/// Load the shader preset at the given path into a filter chain.
|
||||
pub unsafe fn load_from_path<V, E>(
|
||||
|
@ -307,18 +322,7 @@ impl FilterChainVulkan {
|
|||
FilterChainError: From<E>,
|
||||
{
|
||||
let disable_cache = options.map_or(false, |o| o.disable_cache);
|
||||
|
||||
let (passes, semantics) = if !disable_cache {
|
||||
SPIRV::compile_preset_passes::<CachedCompilation<GlslangCompilation>, FilterChainError>(
|
||||
preset.shaders,
|
||||
&preset.textures,
|
||||
)?
|
||||
} else {
|
||||
SPIRV::compile_preset_passes::<GlslangCompilation, FilterChainError>(
|
||||
preset.shaders,
|
||||
&preset.textures,
|
||||
)?
|
||||
};
|
||||
let (passes, semantics) = compile_passes(preset.shaders, &preset.textures, disable_cache)?;
|
||||
|
||||
let device = vulkan.try_into().map_err(From::from)?;
|
||||
|
||||
|
|
Loading…
Reference in a new issue