diff --git a/librashader-presets/src/parse/context.rs b/librashader-presets/src/parse/context.rs index 6a02847..6f9860f 100644 --- a/librashader-presets/src/parse/context.rs +++ b/librashader-presets/src/parse/context.rs @@ -1,10 +1,9 @@ -use nom::AsBytes; use once_cell::sync::Lazy; use regex::bytes::Regex; use rustc_hash::FxHashMap; use std::collections::VecDeque; use std::ffi::{OsStr, OsString}; -use std::fmt::{Debug, Display, Formatter, Write}; +use std::fmt::{Debug, Display, Formatter}; use std::hash::Hash; use std::ops::Add; use std::path::{Component, Path, PathBuf}; diff --git a/librashader-presets/src/parse/value.rs b/librashader-presets/src/parse/value.rs index ff989ea..972d307 100644 --- a/librashader-presets/src/parse/value.rs +++ b/librashader-presets/src/parse/value.rs @@ -4,7 +4,7 @@ use crate::{ScaleFactor, ScaleType}; use nom::bytes::complete::tag; use nom::character::complete::digit1; use nom::combinator::{eof, map_res}; -use std::collections::{HashMap, VecDeque}; +use std::collections::{VecDeque}; use nom::IResult; use num_traits::cast::ToPrimitive; diff --git a/librashader-runtime-d3d11/src/filter_chain.rs b/librashader-runtime-d3d11/src/filter_chain.rs index 0978632..fb9bff5 100644 --- a/librashader-runtime-d3d11/src/filter_chain.rs +++ b/librashader-runtime-d3d11/src/filter_chain.rs @@ -39,6 +39,7 @@ use windows::Win32::Graphics::Direct3D11::{ D3D11_USAGE_DYNAMIC, }; use windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT_R8G8B8A8_UNORM; +use librashader_presets::context::VideoDriver; pub struct FilterMutable { pub(crate) passes_enabled: usize, @@ -98,7 +99,7 @@ impl FilterChainD3D11 { options: Option<&FilterChainOptionsD3D11>, ) -> error::Result { // 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) } } diff --git a/librashader-runtime-d3d12/src/filter_chain.rs b/librashader-runtime-d3d12/src/filter_chain.rs index 79ec6da..6d97242 100644 --- a/librashader-runtime-d3d12/src/filter_chain.rs +++ b/librashader-runtime-d3d12/src/filter_chain.rs @@ -51,6 +51,7 @@ use librashader_runtime::framebuffer::FramebufferInit; use librashader_runtime::render_target::RenderTarget; use librashader_runtime::scaling::ScaleFramebuffer; use rayon::prelude::*; +use librashader_presets::context::VideoDriver; const MIPMAP_RESERVED_WORKHEAP_DESCRIPTORS: usize = 4096; @@ -186,7 +187,7 @@ impl FilterChainD3D12 { options: Option<&FilterChainOptionsD3D12>, ) -> error::Result { // 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) } } diff --git a/librashader-runtime-gl/src/filter_chain/mod.rs b/librashader-runtime-gl/src/filter_chain/mod.rs index fce73f0..bfa7407 100644 --- a/librashader-runtime-gl/src/filter_chain/mod.rs +++ b/librashader-runtime-gl/src/filter_chain/mod.rs @@ -14,6 +14,7 @@ mod parameters; pub(crate) use filter_impl::FilterCommon; use librashader_common::Viewport; +use librashader_presets::context::VideoDriver; /// An OpenGL filter chain. pub struct FilterChainGL { @@ -42,10 +43,7 @@ impl FilterChainGL { }), }) }); - match result { - Err(_) => Err(FilterChainError::GLLoadError), - Ok(res) => res, - } + result.unwrap_or_else(|_| Err(FilterChainError::GLLoadError)) } /// Load the shader preset at the given path into a filter chain. @@ -54,7 +52,7 @@ impl FilterChainGL { options: Option<&FilterChainOptionsGL>, ) -> Result { // 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) } } diff --git a/librashader-runtime-vk/src/filter_chain.rs b/librashader-runtime-vk/src/filter_chain.rs index ac77cad..8480750 100644 --- a/librashader-runtime-vk/src/filter_chain.rs +++ b/librashader-runtime-vk/src/filter_chain.rs @@ -37,6 +37,7 @@ use librashader_runtime::framebuffer::FramebufferInit; use librashader_runtime::render_target::RenderTarget; use librashader_runtime::scaling::ScaleFramebuffer; use rayon::prelude::*; +use librashader_presets::context::VideoDriver; /// A Vulkan device and metadata that is required by the shader runtime. pub struct VulkanObjects { @@ -236,7 +237,7 @@ impl FilterChainVulkan { FilterChainError: From, { // 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) } }