rt: add driver context + path context for FilterChain::load_with_path
This commit is contained in:
parent
a14b36e05b
commit
4da6c98655
|
@ -1,10 +1,9 @@
|
||||||
use nom::AsBytes;
|
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use regex::bytes::Regex;
|
use regex::bytes::Regex;
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::ffi::{OsStr, OsString};
|
use std::ffi::{OsStr, OsString};
|
||||||
use std::fmt::{Debug, Display, Formatter, Write};
|
use std::fmt::{Debug, Display, Formatter};
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
use std::ops::Add;
|
use std::ops::Add;
|
||||||
use std::path::{Component, Path, PathBuf};
|
use std::path::{Component, Path, PathBuf};
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::{ScaleFactor, ScaleType};
|
||||||
use nom::bytes::complete::tag;
|
use nom::bytes::complete::tag;
|
||||||
use nom::character::complete::digit1;
|
use nom::character::complete::digit1;
|
||||||
use nom::combinator::{eof, map_res};
|
use nom::combinator::{eof, map_res};
|
||||||
use std::collections::{HashMap, VecDeque};
|
use std::collections::{VecDeque};
|
||||||
|
|
||||||
use nom::IResult;
|
use nom::IResult;
|
||||||
use num_traits::cast::ToPrimitive;
|
use num_traits::cast::ToPrimitive;
|
||||||
|
|
|
@ -39,6 +39,7 @@ use windows::Win32::Graphics::Direct3D11::{
|
||||||
D3D11_USAGE_DYNAMIC,
|
D3D11_USAGE_DYNAMIC,
|
||||||
};
|
};
|
||||||
use windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT_R8G8B8A8_UNORM;
|
use windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||||
|
use librashader_presets::context::VideoDriver;
|
||||||
|
|
||||||
pub struct FilterMutable {
|
pub struct FilterMutable {
|
||||||
pub(crate) passes_enabled: usize,
|
pub(crate) passes_enabled: usize,
|
||||||
|
@ -98,7 +99,7 @@ impl FilterChainD3D11 {
|
||||||
options: Option<&FilterChainOptionsD3D11>,
|
options: Option<&FilterChainOptionsD3D11>,
|
||||||
) -> error::Result<FilterChainD3D11> {
|
) -> error::Result<FilterChainD3D11> {
|
||||||
// load passes from preset
|
// load passes from preset
|
||||||
let preset = ShaderPreset::try_parse(path)?;
|
let preset = ShaderPreset::try_parse_with_driver_context(path, VideoDriver::Direct3D11)?;
|
||||||
|
|
||||||
unsafe { Self::load_from_preset(preset, device, options) }
|
unsafe { Self::load_from_preset(preset, device, options) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ use librashader_runtime::framebuffer::FramebufferInit;
|
||||||
use librashader_runtime::render_target::RenderTarget;
|
use librashader_runtime::render_target::RenderTarget;
|
||||||
use librashader_runtime::scaling::ScaleFramebuffer;
|
use librashader_runtime::scaling::ScaleFramebuffer;
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
|
use librashader_presets::context::VideoDriver;
|
||||||
|
|
||||||
const MIPMAP_RESERVED_WORKHEAP_DESCRIPTORS: usize = 4096;
|
const MIPMAP_RESERVED_WORKHEAP_DESCRIPTORS: usize = 4096;
|
||||||
|
|
||||||
|
@ -186,7 +187,7 @@ impl FilterChainD3D12 {
|
||||||
options: Option<&FilterChainOptionsD3D12>,
|
options: Option<&FilterChainOptionsD3D12>,
|
||||||
) -> error::Result<FilterChainD3D12> {
|
) -> error::Result<FilterChainD3D12> {
|
||||||
// load passes from preset
|
// load passes from preset
|
||||||
let preset = ShaderPreset::try_parse(path)?;
|
let preset = ShaderPreset::try_parse_with_driver_context(path, VideoDriver::Direct3D12)?;
|
||||||
|
|
||||||
unsafe { Self::load_from_preset(preset, device, options) }
|
unsafe { Self::load_from_preset(preset, device, options) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ mod parameters;
|
||||||
|
|
||||||
pub(crate) use filter_impl::FilterCommon;
|
pub(crate) use filter_impl::FilterCommon;
|
||||||
use librashader_common::Viewport;
|
use librashader_common::Viewport;
|
||||||
|
use librashader_presets::context::VideoDriver;
|
||||||
|
|
||||||
/// An OpenGL filter chain.
|
/// An OpenGL filter chain.
|
||||||
pub struct FilterChainGL {
|
pub struct FilterChainGL {
|
||||||
|
@ -42,10 +43,7 @@ impl FilterChainGL {
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
match result {
|
result.unwrap_or_else(|_| Err(FilterChainError::GLLoadError))
|
||||||
Err(_) => Err(FilterChainError::GLLoadError),
|
|
||||||
Ok(res) => res,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Load the shader preset at the given path into a filter chain.
|
/// Load the shader preset at the given path into a filter chain.
|
||||||
|
@ -54,7 +52,7 @@ impl FilterChainGL {
|
||||||
options: Option<&FilterChainOptionsGL>,
|
options: Option<&FilterChainOptionsGL>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
// load passes from preset
|
// load passes from preset
|
||||||
let preset = ShaderPreset::try_parse(path)?;
|
let preset = ShaderPreset::try_parse_with_driver_context(path, VideoDriver::GlCore)?;
|
||||||
unsafe { Self::load_from_preset(preset, options) }
|
unsafe { Self::load_from_preset(preset, options) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ use librashader_runtime::framebuffer::FramebufferInit;
|
||||||
use librashader_runtime::render_target::RenderTarget;
|
use librashader_runtime::render_target::RenderTarget;
|
||||||
use librashader_runtime::scaling::ScaleFramebuffer;
|
use librashader_runtime::scaling::ScaleFramebuffer;
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
|
use librashader_presets::context::VideoDriver;
|
||||||
|
|
||||||
/// A Vulkan device and metadata that is required by the shader runtime.
|
/// A Vulkan device and metadata that is required by the shader runtime.
|
||||||
pub struct VulkanObjects {
|
pub struct VulkanObjects {
|
||||||
|
@ -236,7 +237,7 @@ impl FilterChainVulkan {
|
||||||
FilterChainError: From<E>,
|
FilterChainError: From<E>,
|
||||||
{
|
{
|
||||||
// load passes from preset
|
// load passes from preset
|
||||||
let preset = ShaderPreset::try_parse(path)?;
|
let preset = ShaderPreset::try_parse_with_driver_context(path, VideoDriver::Vulkan)?;
|
||||||
|
|
||||||
unsafe { Self::load_from_preset(preset, vulkan, options) }
|
unsafe { Self::load_from_preset(preset, vulkan, options) }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue