diff --git a/librashader-runtime-d3d11/src/lib.rs b/librashader-runtime-d3d11/src/lib.rs index cd49fc3..2e02ffc 100644 --- a/librashader-runtime-d3d11/src/lib.rs +++ b/librashader-runtime-d3d11/src/lib.rs @@ -13,7 +13,6 @@ mod filter_chain; mod filter_pass; mod framebuffer; mod graphics_pipeline; -mod parameters; mod samplers; mod texture; mod util; @@ -21,6 +20,9 @@ mod util; pub mod error; pub mod options; +use librashader_runtime::impl_filter_chain_parameters; +impl_filter_chain_parameters!(FilterChainD3D11); + pub use filter_chain::FilterChainD3D11; pub use texture::D3D11InputView; pub use texture::D3D11OutputView; diff --git a/librashader-runtime-d3d11/src/parameters.rs b/librashader-runtime-d3d11/src/parameters.rs deleted file mode 100644 index f2e1b92..0000000 --- a/librashader-runtime-d3d11/src/parameters.rs +++ /dev/null @@ -1,40 +0,0 @@ -use crate::FilterChainD3D11; -use librashader_runtime::parameters::FilterChainParameters; -use std::collections::hash_map::Iter; - -impl FilterChainParameters for FilterChainD3D11 { - fn get_enabled_pass_count(&self) -> usize { - self.common.config.passes_enabled - } - - fn set_enabled_pass_count(&mut self, count: usize) { - self.common.config.passes_enabled = count - } - - fn enumerate_parameters(&self) -> Iter { - self.common.config.parameters.iter() - } - - fn get_parameter(&self, parameter: &str) -> Option { - self.common - .config - .parameters - .get::(parameter.as_ref()) - .copied() - } - - fn set_parameter(&mut self, parameter: &str, new_value: f32) -> Option { - if let Some(value) = self - .common - .config - .parameters - .get_mut::(parameter.as_ref()) - { - let old = *value; - *value = new_value; - Some(old) - } else { - None - } - } -} diff --git a/librashader-runtime-d3d12/src/lib.rs b/librashader-runtime-d3d12/src/lib.rs index d3b710d..70eb869 100644 --- a/librashader-runtime-d3d12/src/lib.rs +++ b/librashader-runtime-d3d12/src/lib.rs @@ -12,7 +12,6 @@ mod framebuffer; mod graphics_pipeline; mod luts; mod mipmap; -mod parameters; mod samplers; mod texture; mod util; @@ -20,6 +19,8 @@ mod util; pub mod error; pub mod options; +use librashader_runtime::impl_filter_chain_parameters; +impl_filter_chain_parameters!(FilterChainD3D12); pub use filter_chain::FilterChainD3D12; pub use texture::D3D12InputImage; pub use texture::D3D12OutputView; diff --git a/librashader-runtime-d3d12/src/parameters.rs b/librashader-runtime-d3d12/src/parameters.rs deleted file mode 100644 index 535a8b9..0000000 --- a/librashader-runtime-d3d12/src/parameters.rs +++ /dev/null @@ -1,40 +0,0 @@ -use crate::filter_chain::FilterChainD3D12; -use librashader_runtime::parameters::FilterChainParameters; -use std::collections::hash_map::Iter; - -impl FilterChainParameters for FilterChainD3D12 { - fn get_enabled_pass_count(&self) -> usize { - self.common.config.passes_enabled - } - - fn set_enabled_pass_count(&mut self, count: usize) { - self.common.config.passes_enabled = count - } - - fn enumerate_parameters(&self) -> Iter { - self.common.config.parameters.iter() - } - - fn get_parameter(&self, parameter: &str) -> Option { - self.common - .config - .parameters - .get::(parameter.as_ref()) - .copied() - } - - fn set_parameter(&mut self, parameter: &str, new_value: f32) -> Option { - if let Some(value) = self - .common - .config - .parameters - .get_mut::(parameter.as_ref()) - { - let old = *value; - *value = new_value; - Some(old) - } else { - None - } - } -} diff --git a/librashader-runtime-metal/src/lib.rs b/librashader-runtime-metal/src/lib.rs index 1cf0ec4..debc419 100644 --- a/librashader-runtime-metal/src/lib.rs +++ b/librashader-runtime-metal/src/lib.rs @@ -1,3 +1,4 @@ +#![cfg(target_vendor = "apple")] mod draw_quad; mod error; mod graphics_pipeline; diff --git a/librashader-runtime-vk/src/lib.rs b/librashader-runtime-vk/src/lib.rs index 783ec8f..bc6334b 100644 --- a/librashader-runtime-vk/src/lib.rs +++ b/librashader-runtime-vk/src/lib.rs @@ -13,7 +13,6 @@ mod framebuffer; mod graphics_pipeline; mod luts; mod memory; -mod parameters; mod queue_selection; mod samplers; mod texture; @@ -24,6 +23,9 @@ pub use filter_chain::VulkanInstance; pub use filter_chain::VulkanObjects; pub use texture::VulkanImage; +use librashader_runtime::impl_filter_chain_parameters; +impl_filter_chain_parameters!(FilterChainVulkan); + pub mod error; pub mod options; mod render_pass; diff --git a/librashader-runtime-vk/src/parameters.rs b/librashader-runtime-vk/src/parameters.rs deleted file mode 100644 index 8f36634..0000000 --- a/librashader-runtime-vk/src/parameters.rs +++ /dev/null @@ -1,40 +0,0 @@ -use crate::FilterChainVulkan; -use librashader_runtime::parameters::FilterChainParameters; -use std::collections::hash_map::Iter; - -impl FilterChainParameters for FilterChainVulkan { - fn get_enabled_pass_count(&self) -> usize { - self.common.config.passes_enabled - } - - fn set_enabled_pass_count(&mut self, count: usize) { - self.common.config.passes_enabled = count - } - - fn enumerate_parameters(&self) -> Iter { - self.common.config.parameters.iter() - } - - fn get_parameter(&self, parameter: &str) -> Option { - self.common - .config - .parameters - .get::(parameter.as_ref()) - .copied() - } - - fn set_parameter(&mut self, parameter: &str, new_value: f32) -> Option { - if let Some(value) = self - .common - .config - .parameters - .get_mut::(parameter.as_ref()) - { - let old = *value; - *value = new_value; - Some(old) - } else { - None - } - } -} diff --git a/librashader-runtime-wgpu/src/lib.rs b/librashader-runtime-wgpu/src/lib.rs index efc3808..61be618 100644 --- a/librashader-runtime-wgpu/src/lib.rs +++ b/librashader-runtime-wgpu/src/lib.rs @@ -25,3 +25,6 @@ pub use framebuffer::WgpuOutputView; pub mod error; pub mod options; + +use librashader_runtime::impl_filter_chain_parameters; +impl_filter_chain_parameters!(FilterChainWgpu); diff --git a/librashader-runtime/src/parameters.rs b/librashader-runtime/src/parameters.rs index 949b04b..b815ef2 100644 --- a/librashader-runtime/src/parameters.rs +++ b/librashader-runtime/src/parameters.rs @@ -17,3 +17,46 @@ pub trait FilterChainParameters { /// Returns `None` if the parameter did not exist, or the old value if successful. fn set_parameter(&mut self, parameter: &str, new_value: f32) -> Option; } + +#[macro_export] +macro_rules! impl_filter_chain_parameters { + ($ty:ty) => { + impl ::librashader_runtime::parameters::FilterChainParameters for $ty { + fn get_enabled_pass_count(&self) -> usize { + self.common.config.passes_enabled + } + + fn set_enabled_pass_count(&mut self, count: usize) { + self.common.config.passes_enabled = count + } + + fn enumerate_parameters(&self) -> ::std::collections::hash_map::Iter { + self.common.config.parameters.iter() + } + + fn get_parameter(&self, parameter: &str) -> Option { + self.common + .config + .parameters + .get::(parameter.as_ref()) + .copied() + } + + fn set_parameter(&mut self, parameter: &str, new_value: f32) -> Option { + if let Some(value) = self + .common + .config + .parameters + .get_mut::(parameter.as_ref()) + { + let old = *value; + *value = new_value; + Some(old) + } else { + None + } + } + } + }; +} +