rt: auto-impl parameters
This commit is contained in:
parent
8dc0e0d100
commit
1aedb1bea7
|
@ -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;
|
||||
|
|
|
@ -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<String, f32> {
|
||||
self.common.config.parameters.iter()
|
||||
}
|
||||
|
||||
fn get_parameter(&self, parameter: &str) -> Option<f32> {
|
||||
self.common
|
||||
.config
|
||||
.parameters
|
||||
.get::<str>(parameter.as_ref())
|
||||
.copied()
|
||||
}
|
||||
|
||||
fn set_parameter(&mut self, parameter: &str, new_value: f32) -> Option<f32> {
|
||||
if let Some(value) = self
|
||||
.common
|
||||
.config
|
||||
.parameters
|
||||
.get_mut::<str>(parameter.as_ref())
|
||||
{
|
||||
let old = *value;
|
||||
*value = new_value;
|
||||
Some(old)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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<String, f32> {
|
||||
self.common.config.parameters.iter()
|
||||
}
|
||||
|
||||
fn get_parameter(&self, parameter: &str) -> Option<f32> {
|
||||
self.common
|
||||
.config
|
||||
.parameters
|
||||
.get::<str>(parameter.as_ref())
|
||||
.copied()
|
||||
}
|
||||
|
||||
fn set_parameter(&mut self, parameter: &str, new_value: f32) -> Option<f32> {
|
||||
if let Some(value) = self
|
||||
.common
|
||||
.config
|
||||
.parameters
|
||||
.get_mut::<str>(parameter.as_ref())
|
||||
{
|
||||
let old = *value;
|
||||
*value = new_value;
|
||||
Some(old)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
#![cfg(target_vendor = "apple")]
|
||||
mod draw_quad;
|
||||
mod error;
|
||||
mod graphics_pipeline;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<String, f32> {
|
||||
self.common.config.parameters.iter()
|
||||
}
|
||||
|
||||
fn get_parameter(&self, parameter: &str) -> Option<f32> {
|
||||
self.common
|
||||
.config
|
||||
.parameters
|
||||
.get::<str>(parameter.as_ref())
|
||||
.copied()
|
||||
}
|
||||
|
||||
fn set_parameter(&mut self, parameter: &str, new_value: f32) -> Option<f32> {
|
||||
if let Some(value) = self
|
||||
.common
|
||||
.config
|
||||
.parameters
|
||||
.get_mut::<str>(parameter.as_ref())
|
||||
{
|
||||
let old = *value;
|
||||
*value = new_value;
|
||||
Some(old)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
|
|
|
@ -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<f32>;
|
||||
}
|
||||
|
||||
#[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<String, f32> {
|
||||
self.common.config.parameters.iter()
|
||||
}
|
||||
|
||||
fn get_parameter(&self, parameter: &str) -> Option<f32> {
|
||||
self.common
|
||||
.config
|
||||
.parameters
|
||||
.get::<str>(parameter.as_ref())
|
||||
.copied()
|
||||
}
|
||||
|
||||
fn set_parameter(&mut self, parameter: &str, new_value: f32) -> Option<f32> {
|
||||
if let Some(value) = self
|
||||
.common
|
||||
.config
|
||||
.parameters
|
||||
.get_mut::<str>(parameter.as_ref())
|
||||
{
|
||||
let old = *value;
|
||||
*value = new_value;
|
||||
Some(old)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue