rt: separate out meta information to its own struct

This commit is contained in:
chyyran 2024-09-30 19:02:55 -04:00 committed by Ronny Chan
parent b395b94a40
commit 859d16e64e
21 changed files with 228 additions and 223 deletions

View file

@ -16,8 +16,7 @@ members = [
"librashader-cache", "librashader-cache",
"librashader-capi", "librashader-capi",
"librashader-build-script", "librashader-build-script",
"librashader-cli" "librashader-cli"]
]
resolver = "2" resolver = "2"
[workspace.dependencies] [workspace.dependencies]

View file

@ -6,8 +6,8 @@ use crate::ffi::extern_fn;
use librashader::runtime::vk::{ use librashader::runtime::vk::{
FilterChain, FilterChainOptions, FrameOptions, VulkanImage, VulkanInstance, FilterChain, FilterChainOptions, FrameOptions, VulkanImage, VulkanInstance,
}; };
use std::ffi::CStr;
use std::ffi::c_char; use std::ffi::c_char;
use std::ffi::CStr;
use std::mem::MaybeUninit; use std::mem::MaybeUninit;
use std::ptr::NonNull; use std::ptr::NonNull;
use std::slice; use std::slice;

View file

@ -1,6 +1,9 @@
use crate::parse::remove_if; use crate::parse::remove_if;
use crate::parse::value::Value; use crate::parse::value::Value;
use crate::{ParameterConfig, Scale2D, Scaling, ShaderPassConfig, ShaderPreset, TextureConfig}; use crate::{
ParameterConfig, Scale2D, Scaling, ShaderPassConfig, ShaderPassMeta, ShaderPreset,
TextureConfig,
};
use vec_extract_if_polyfill::MakeExtractIf; use vec_extract_if_polyfill::MakeExtractIf;
pub fn resolve_values(mut values: Vec<Value>) -> ShaderPreset { pub fn resolve_values(mut values: Vec<Value>) -> ShaderPreset {
@ -114,63 +117,65 @@ pub fn resolve_values(mut values: Vec<Value>) -> ShaderPreset {
} }
let shader = ShaderPassConfig { let shader = ShaderPassConfig {
id,
name, name,
alias: shader_values.iter().find_map(|f| match f { meta: ShaderPassMeta {
Value::Alias(_, value) => Some(value.clone()), id,
_ => None, alias: shader_values.iter().find_map(|f| match f {
}), Value::Alias(_, value) => Some(value.clone()),
filter: shader_values
.iter()
.find_map(|f| match f {
Value::FilterMode(_, value) => Some(*value),
_ => None, _ => None,
}) }),
.unwrap_or_default(), filter: shader_values
wrap_mode: shader_values .iter()
.iter() .find_map(|f| match f {
.find_map(|f| match f { Value::FilterMode(_, value) => Some(*value),
Value::WrapMode(_, value) => Some(*value), _ => None,
_ => None, })
}) .unwrap_or_default(),
.unwrap_or_default(), wrap_mode: shader_values
frame_count_mod: shader_values .iter()
.iter() .find_map(|f| match f {
.find_map(|f| match f { Value::WrapMode(_, value) => Some(*value),
Value::FrameCountMod(_, value) => Some(*value), _ => None,
_ => None, })
}) .unwrap_or_default(),
.unwrap_or(0), frame_count_mod: shader_values
srgb_framebuffer: shader_values .iter()
.iter() .find_map(|f| match f {
.find_map(|f| match f { Value::FrameCountMod(_, value) => Some(*value),
Value::SrgbFramebuffer(_, value) => Some(*value), _ => None,
_ => None, })
}) .unwrap_or(0),
.unwrap_or(false), srgb_framebuffer: shader_values
float_framebuffer: shader_values .iter()
.iter() .find_map(|f| match f {
.find_map(|f| match f { Value::SrgbFramebuffer(_, value) => Some(*value),
Value::FloatFramebuffer(_, value) => Some(*value), _ => None,
_ => None, })
}) .unwrap_or(false),
.unwrap_or(false), float_framebuffer: shader_values
mipmap_input: shader_values .iter()
.iter() .find_map(|f| match f {
.find_map(|f| match f { Value::FloatFramebuffer(_, value) => Some(*value),
Value::MipmapInput(_, value) => Some(*value), _ => None,
_ => None, })
}) .unwrap_or(false),
.unwrap_or(false), mipmap_input: shader_values
scaling: Scale2D { .iter()
valid: scale_valid, .find_map(|f| match f {
x: Scaling { Value::MipmapInput(_, value) => Some(*value),
scale_type: scale_type_x.unwrap_or_default(), _ => None,
factor: scale_x.unwrap_or_default(), })
}, .unwrap_or(false),
y: Scaling { scaling: Scale2D {
scale_type: scale_type_y.unwrap_or_default(), valid: scale_valid,
factor: scale_y.unwrap_or_default(), x: Scaling {
scale_type: scale_type_x.unwrap_or_default(),
factor: scale_x.unwrap_or_default(),
},
y: Scaling {
scale_type: scale_type_y.unwrap_or_default(),
factor: scale_y.unwrap_or_default(),
},
}, },
}, },
}; };

View file

@ -9,10 +9,17 @@ use std::str::FromStr;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ShaderPassConfig { pub struct ShaderPassConfig {
/// The index of the shader pass relative to its parent preset.
pub id: i32,
/// The fully qualified path to the shader pass source file. /// The fully qualified path to the shader pass source file.
pub name: PathBuf, pub name: PathBuf,
/// Meta information about the shader pass
pub meta: ShaderPassMeta,
}
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ShaderPassMeta {
/// The index of the shader pass relative to its parent preset.
pub id: i32,
/// The alias of the shader pass if available. /// The alias of the shader pass if available.
pub alias: Option<ShortString>, pub alias: Option<ShortString>,
/// The filtering mode that this shader pass should expect. /// The filtering mode that this shader pass should expect.
@ -31,7 +38,7 @@ pub struct ShaderPassConfig {
pub scaling: Scale2D, pub scaling: Scale2D,
} }
impl ShaderPassConfig { impl ShaderPassMeta {
/// If the framebuffer expects a different format than what was defined in the /// If the framebuffer expects a different format than what was defined in the
/// shader source, returns such format. /// shader source, returns such format.
#[inline(always)] #[inline(always)]

View file

@ -7,7 +7,7 @@ use crate::reflect::semantics::{
}; };
use librashader_common::map::{FastHashMap, ShortString}; use librashader_common::map::{FastHashMap, ShortString};
use librashader_preprocess::{PreprocessError, ShaderSource}; use librashader_preprocess::{PreprocessError, ShaderSource};
use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig}; use librashader_presets::{ShaderPassConfig, ShaderPassMeta, ShaderPreset, TextureConfig};
/// Artifacts of a reflected and compiled shader pass. /// Artifacts of a reflected and compiled shader pass.
/// ///
@ -27,7 +27,7 @@ use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig};
/// ``` /// ```
/// ///
/// This allows a runtime to not name the backing type of the compiled artifact if not necessary. /// This allows a runtime to not name the backing type of the compiled artifact if not necessary.
pub type ShaderPassArtifact<T> = (ShaderPassConfig, ShaderSource, CompilerBackend<T>); pub type ShaderPassArtifact<T> = (ShaderPassMeta, ShaderSource, CompilerBackend<T>);
impl<T: OutputTarget> CompilePresetTarget for T {} impl<T: OutputTarget> CompilePresetTarget for T {}
@ -101,22 +101,22 @@ where
}), }),
); );
} }
Ok::<_, E>((shader, source, reflect)) Ok::<_, E>((shader.meta, source, reflect))
}) })
.collect::<Result<Vec<(ShaderPassConfig, ShaderSource, CompilerBackend<_>)>, E>>()?; .collect::<Result<Vec<(ShaderPassMeta, ShaderSource, CompilerBackend<_>)>, E>>()?;
for (config, source, _) in &passes { for (meta, source, _) in &passes {
insert_pass_semantics( insert_pass_semantics(
&mut uniform_semantics, &mut uniform_semantics,
&mut texture_semantics, &mut texture_semantics,
config.alias.as_ref(), meta.alias.as_ref(),
config.id as usize, meta.id as usize,
); );
insert_pass_semantics( insert_pass_semantics(
&mut uniform_semantics, &mut uniform_semantics,
&mut texture_semantics, &mut texture_semantics,
source.name.as_ref(), source.name.as_ref(),
config.id as usize, meta.id as usize,
); );
} }
@ -251,14 +251,14 @@ impl ShaderSemantics {
insert_pass_semantics( insert_pass_semantics(
&mut uniform_semantics, &mut uniform_semantics,
&mut texture_semantics, &mut texture_semantics,
config.alias.as_ref(), config.meta.alias.as_ref(),
config.id as usize, config.meta.id as usize,
); );
insert_pass_semantics( insert_pass_semantics(
&mut uniform_semantics, &mut uniform_semantics,
&mut texture_semantics, &mut texture_semantics,
source.name.as_ref(), source.name.as_ref(),
config.id as usize, config.meta.id as usize,
); );
insert_lut_semantics( insert_lut_semantics(
preset.textures.as_slice(), preset.textures.as_slice(),

View file

@ -328,7 +328,7 @@ impl FilterChainD3D11 {
uniform_buffer: ubo_cbuffer, uniform_buffer: ubo_cbuffer,
push_buffer: push_cbuffer, push_buffer: push_cbuffer,
source, source,
config, meta: config,
}) })
}; };
@ -425,8 +425,8 @@ impl FilterChainD3D11 {
} }
let options = options.unwrap_or(&self.default_options); let options = options.unwrap_or(&self.default_options);
let filter = passes[0].config.filter; let filter = passes[0].meta.filter;
let wrap_mode = passes[0].config.wrap_mode; let wrap_mode = passes[0].meta.wrap_mode;
for (texture, fbo) in self for (texture, fbo) in self
.common .common
@ -467,8 +467,8 @@ impl FilterChainD3D11 {
{ {
*texture = Some(InputTexture::from_framebuffer( *texture = Some(InputTexture::from_framebuffer(
fbo, fbo,
pass.config.wrap_mode, pass.meta.wrap_mode,
pass.config.filter, pass.meta.filter,
)?); )?);
} }
@ -479,14 +479,14 @@ impl FilterChainD3D11 {
self.common.draw_quad.bind_vbo_for_frame(ctx); self.common.draw_quad.bind_vbo_for_frame(ctx);
for (index, pass) in pass.iter_mut().enumerate() { for (index, pass) in pass.iter_mut().enumerate() {
source.filter = pass.config.filter; source.filter = pass.meta.filter;
source.wrap_mode = pass.config.wrap_mode; source.wrap_mode = pass.meta.wrap_mode;
let target = &self.output_framebuffers[index]; let target = &self.output_framebuffers[index];
pass.draw( pass.draw(
ctx, ctx,
index, index,
&self.common, &self.common,
pass.config.get_frame_count(frame_count), pass.meta.get_frame_count(frame_count),
options, options,
viewport, viewport,
&original, &original,
@ -497,8 +497,8 @@ impl FilterChainD3D11 {
source = InputTexture { source = InputTexture {
view: target.create_shader_resource_view()?, view: target.create_shader_resource_view()?,
filter: pass.config.filter, filter: pass.meta.filter,
wrap_mode: pass.config.wrap_mode, wrap_mode: pass.meta.wrap_mode,
}; };
self.common.output_textures[index] = Some(source.clone()); self.common.output_textures[index] = Some(source.clone());
} }
@ -507,8 +507,8 @@ impl FilterChainD3D11 {
assert_eq!(last.len(), 1); assert_eq!(last.len(), 1);
if let Some(pass) = last.iter_mut().next() { if let Some(pass) = last.iter_mut().next() {
let index = passes_len - 1; let index = passes_len - 1;
source.filter = pass.config.filter; source.filter = pass.meta.filter;
source.wrap_mode = pass.config.wrap_mode; source.wrap_mode = pass.meta.wrap_mode;
// Draw to output_framebuffers for proper handling of feedback. // Draw to output_framebuffers for proper handling of feedback.
@ -518,7 +518,7 @@ impl FilterChainD3D11 {
&ctx, &ctx,
index, index,
&self.common, &self.common,
pass.config.get_frame_count(frame_count), pass.meta.get_frame_count(frame_count),
options, options,
viewport, viewport,
&original, &original,
@ -535,7 +535,7 @@ impl FilterChainD3D11 {
&ctx, &ctx,
index, index,
&self.common, &self.common,
pass.config.get_frame_count(frame_count), pass.meta.get_frame_count(frame_count),
options, options,
viewport, viewport,
&original, &original,

View file

@ -6,7 +6,7 @@ use windows::Win32::Foundation::RECT;
use librashader_common::map::FastHashMap; use librashader_common::map::FastHashMap;
use librashader_common::{ImageFormat, Size, Viewport}; use librashader_common::{ImageFormat, Size, Viewport};
use librashader_preprocess::ShaderSource; use librashader_preprocess::ShaderSource;
use librashader_presets::ShaderPassConfig; use librashader_presets::ShaderPassMeta;
use librashader_reflect::reflect::semantics::{ use librashader_reflect::reflect::semantics::{
BindingStage, MemberOffset, TextureBinding, UniformBinding, BindingStage, MemberOffset, TextureBinding, UniformBinding,
}; };
@ -47,7 +47,7 @@ pub struct FilterPass {
pub uniform_buffer: Option<ConstantBufferBinding>, pub uniform_buffer: Option<ConstantBufferBinding>,
pub push_buffer: Option<ConstantBufferBinding>, pub push_buffer: Option<ConstantBufferBinding>,
pub source: ShaderSource, pub source: ShaderSource,
pub config: ShaderPassConfig, pub meta: ShaderPassMeta,
} }
// https://doc.rust-lang.org/nightly/core/array/fn.from_fn.html is not ~const :( // https://doc.rust-lang.org/nightly/core/array/fn.from_fn.html is not ~const :(
@ -90,8 +90,8 @@ impl FilterPassMeta for FilterPass {
self.source.format self.source.format
} }
fn config(&self) -> &ShaderPassConfig { fn meta(&self) -> &ShaderPassMeta {
&self.config &self.meta
} }
} }
@ -157,7 +157,7 @@ impl FilterPass {
output: RenderTarget<ID3D11RenderTargetView>, output: RenderTarget<ID3D11RenderTargetView>,
vbo_type: QuadType, vbo_type: QuadType,
) -> error::Result<()> { ) -> error::Result<()> {
if self.config.mipmap_input && !parent.disable_mipmaps { if self.meta.mipmap_input && !parent.disable_mipmaps {
unsafe { unsafe {
ctx.GenerateMips(&source.view); ctx.GenerateMips(&source.view);
} }

View file

@ -619,7 +619,7 @@ impl FilterChainD3D12 {
uniform_bindings, uniform_bindings,
uniform_storage, uniform_storage,
pipeline: graphics_pipeline, pipeline: graphics_pipeline,
config, meta: config,
texture_heap, texture_heap,
sampler_heap, sampler_heap,
source, source,
@ -708,8 +708,8 @@ impl FilterChainD3D12 {
let options = options.unwrap_or(&self.default_options); let options = options.unwrap_or(&self.default_options);
let filter = passes[0].config.filter; let filter = passes[0].meta.filter;
let wrap_mode = passes[0].config.wrap_mode; let wrap_mode = passes[0].meta.wrap_mode;
for ((texture, fbo), pass) in self for ((texture, fbo), pass) in self
.common .common
@ -720,8 +720,8 @@ impl FilterChainD3D12 {
{ {
*texture = Some(fbo.create_shader_resource_view( *texture = Some(fbo.create_shader_resource_view(
&mut self.staging_heap, &mut self.staging_heap,
pass.config.filter, pass.meta.filter,
pass.config.wrap_mode, pass.meta.wrap_mode,
)?); )?);
} }
@ -771,13 +771,13 @@ impl FilterChainD3D12 {
// refresh inputs // refresh inputs
self.common.feedback_textures[index] = Some(feedback.create_shader_resource_view( self.common.feedback_textures[index] = Some(feedback.create_shader_resource_view(
&mut self.staging_heap, &mut self.staging_heap,
pass.config.filter, pass.meta.filter,
pass.config.wrap_mode, pass.meta.wrap_mode,
)?); )?);
self.common.output_textures[index] = Some(output.create_shader_resource_view( self.common.output_textures[index] = Some(output.create_shader_resource_view(
&mut self.staging_heap, &mut self.staging_heap,
pass.config.filter, pass.meta.filter,
pass.config.wrap_mode, pass.meta.wrap_mode,
)?); )?);
Ok(()) Ok(())
@ -800,8 +800,8 @@ impl FilterChainD3D12 {
self.common.draw_quad.bind_vertices_for_frame(cmd); self.common.draw_quad.bind_vertices_for_frame(cmd);
for (index, pass) in pass.iter_mut().enumerate() { for (index, pass) in pass.iter_mut().enumerate() {
source.filter = pass.config.filter; source.filter = pass.meta.filter;
source.wrap_mode = pass.config.wrap_mode; source.wrap_mode = pass.meta.wrap_mode;
let target = &self.output_framebuffers[index]; let target = &self.output_framebuffers[index];
@ -828,7 +828,7 @@ impl FilterChainD3D12 {
cmd, cmd,
index, index,
&self.common, &self.common,
pass.config.get_frame_count(frame_count), pass.meta.get_frame_count(frame_count),
options, options,
viewport, viewport,
&original, &original,
@ -872,8 +872,8 @@ impl FilterChainD3D12 {
if let Some(pass) = last.iter_mut().next() { if let Some(pass) = last.iter_mut().next() {
let index = passes_len - 1; let index = passes_len - 1;
source.filter = pass.config.filter; source.filter = pass.meta.filter;
source.wrap_mode = pass.config.wrap_mode; source.wrap_mode = pass.meta.wrap_mode;
if self.draw_last_pass_feedback { if self.draw_last_pass_feedback {
let feedback_target = &self.output_framebuffers[index]; let feedback_target = &self.output_framebuffers[index];
@ -900,7 +900,7 @@ impl FilterChainD3D12 {
cmd, cmd,
index, index,
&self.common, &self.common,
pass.config.get_frame_count(frame_count), pass.meta.get_frame_count(frame_count),
options, options,
viewport, viewport,
&original, &original,
@ -931,7 +931,7 @@ impl FilterChainD3D12 {
cmd, cmd,
passes_len - 1, passes_len - 1,
&self.common, &self.common,
pass.config.get_frame_count(frame_count), pass.meta.get_frame_count(frame_count),
options, options,
viewport, viewport,
&original, &original,

View file

@ -10,7 +10,7 @@ use d3d12_descriptor_heap::D3D12DescriptorHeapSlot;
use librashader_common::map::FastHashMap; use librashader_common::map::FastHashMap;
use librashader_common::{ImageFormat, Size, Viewport}; use librashader_common::{ImageFormat, Size, Viewport};
use librashader_preprocess::ShaderSource; use librashader_preprocess::ShaderSource;
use librashader_presets::ShaderPassConfig; use librashader_presets::ShaderPassMeta;
use librashader_reflect::reflect::semantics::{MemberOffset, TextureBinding, UniformBinding}; use librashader_reflect::reflect::semantics::{MemberOffset, TextureBinding, UniformBinding};
use librashader_reflect::reflect::ShaderReflection; use librashader_reflect::reflect::ShaderReflection;
use librashader_runtime::binding::{BindSemantics, TextureInput, UniformInputs}; use librashader_runtime::binding::{BindSemantics, TextureInput, UniformInputs};
@ -30,7 +30,7 @@ use windows::Win32::Graphics::Direct3D12::{
pub(crate) struct FilterPass { pub(crate) struct FilterPass {
pub(crate) pipeline: D3D12GraphicsPipeline, pub(crate) pipeline: D3D12GraphicsPipeline,
pub(crate) reflection: ShaderReflection, pub(crate) reflection: ShaderReflection,
pub(crate) config: ShaderPassConfig, pub(crate) meta: ShaderPassMeta,
pub(crate) uniform_bindings: FastHashMap<UniformBinding, MemberOffset>, pub(crate) uniform_bindings: FastHashMap<UniformBinding, MemberOffset>,
pub uniform_storage: pub uniform_storage:
UniformStorage<NoUniformBinder, Option<()>, RawD3D12Buffer, RawD3D12Buffer>, UniformStorage<NoUniformBinder, Option<()>, RawD3D12Buffer, RawD3D12Buffer>,
@ -77,8 +77,8 @@ impl FilterPassMeta for FilterPass {
self.source.format self.source.format
} }
fn config(&self) -> &ShaderPassConfig { fn meta(&self) -> &ShaderPassMeta {
&self.config &self.meta
} }
} }

View file

@ -170,7 +170,7 @@ impl FilterChainD3D9 {
uniform_storage, uniform_storage,
gl_halfpixel, gl_halfpixel,
source, source,
config, meta: config,
}) })
}; };
@ -309,8 +309,8 @@ impl FilterChainD3D9 {
} }
let options = options.unwrap_or(&self.default_options); let options = options.unwrap_or(&self.default_options);
let filter = passes[0].config.filter; let filter = passes[0].meta.filter;
let wrap_mode = passes[0].config.wrap_mode; let wrap_mode = passes[0].meta.wrap_mode;
for (texture, fbo) in self for (texture, fbo) in self
.common .common
@ -351,11 +351,7 @@ impl FilterChainD3D9 {
.zip(self.feedback_framebuffers.iter()) .zip(self.feedback_framebuffers.iter())
.zip(passes.iter()) .zip(passes.iter())
{ {
*texture = Some(fbo.as_input( *texture = Some(fbo.as_input(pass.meta.filter, pass.meta.filter, pass.meta.wrap_mode));
pass.config.filter,
pass.config.filter,
pass.config.wrap_mode,
));
} }
let passes_len = passes.len(); let passes_len = passes.len();
@ -363,16 +359,16 @@ impl FilterChainD3D9 {
let state_guard = D3D9State::new(&self.common.d3d9)?; let state_guard = D3D9State::new(&self.common.d3d9)?;
for (index, pass) in pass.iter_mut().enumerate() { for (index, pass) in pass.iter_mut().enumerate() {
source.filter = pass.config.filter; source.filter = pass.meta.filter;
source.wrap = pass.config.wrap_mode; source.wrap = pass.meta.wrap_mode;
source.is_srgb = pass.config.srgb_framebuffer; source.is_srgb = pass.meta.srgb_framebuffer;
let target = &self.output_framebuffers[index]; let target = &self.output_framebuffers[index];
let target_rtv = target.as_output()?; let target_rtv = target.as_output()?;
pass.draw( pass.draw(
&self.common.d3d9, &self.common.d3d9,
index, index,
&self.common, &self.common,
pass.config.get_frame_count(frame_count), pass.meta.get_frame_count(frame_count),
options, options,
viewport, viewport,
&original, &original,
@ -383,10 +379,10 @@ impl FilterChainD3D9 {
source = D3D9InputTexture { source = D3D9InputTexture {
handle: target.handle.clone(), handle: target.handle.clone(),
filter: pass.config.filter, filter: pass.meta.filter,
wrap: pass.config.wrap_mode, wrap: pass.meta.wrap_mode,
mipmode: pass.config.filter, mipmode: pass.meta.filter,
is_srgb: pass.config.srgb_framebuffer, is_srgb: pass.meta.srgb_framebuffer,
}; };
self.common.output_textures[index] = Some(source.clone()); self.common.output_textures[index] = Some(source.clone());
} }
@ -395,9 +391,9 @@ impl FilterChainD3D9 {
assert_eq!(last.len(), 1); assert_eq!(last.len(), 1);
if let Some(pass) = last.iter_mut().next() { if let Some(pass) = last.iter_mut().next() {
let index = passes_len - 1; let index = passes_len - 1;
source.filter = pass.config.filter; source.filter = pass.meta.filter;
source.wrap = pass.config.wrap_mode; source.wrap = pass.meta.wrap_mode;
source.is_srgb = pass.config.srgb_framebuffer; source.is_srgb = pass.meta.srgb_framebuffer;
if self.draw_last_pass_feedback { if self.draw_last_pass_feedback {
let feedback_target = &self.output_framebuffers[index]; let feedback_target = &self.output_framebuffers[index];
@ -407,7 +403,7 @@ impl FilterChainD3D9 {
&self.common.d3d9, &self.common.d3d9,
index, index,
&self.common, &self.common,
pass.config.get_frame_count(frame_count), pass.meta.get_frame_count(frame_count),
options, options,
viewport, viewport,
&original, &original,
@ -421,7 +417,7 @@ impl FilterChainD3D9 {
&self.common.d3d9, &self.common.d3d9,
index, index,
&self.common, &self.common,
pass.config.get_frame_count(frame_count), pass.meta.get_frame_count(frame_count),
options, options,
viewport, viewport,
&original, &original,

View file

@ -8,7 +8,7 @@ use librashader_common::map::FastHashMap;
use librashader_common::GetSize; use librashader_common::GetSize;
use librashader_common::{ImageFormat, Size, Viewport}; use librashader_common::{ImageFormat, Size, Viewport};
use librashader_preprocess::ShaderSource; use librashader_preprocess::ShaderSource;
use librashader_presets::ShaderPassConfig; use librashader_presets::ShaderPassMeta;
use librashader_reflect::reflect::semantics::{TextureBinding, UniformBinding}; use librashader_reflect::reflect::semantics::{TextureBinding, UniformBinding};
use librashader_reflect::reflect::ShaderReflection; use librashader_reflect::reflect::ShaderReflection;
use librashader_runtime::binding::{BindSemantics, UniformInputs}; use librashader_runtime::binding::{BindSemantics, UniformInputs};
@ -28,7 +28,7 @@ pub struct FilterPass {
pub pixel_shader: IDirect3DPixelShader9, pub pixel_shader: IDirect3DPixelShader9,
pub uniform_bindings: FastHashMap<UniformBinding, ConstantRegister>, pub uniform_bindings: FastHashMap<UniformBinding, ConstantRegister>,
pub source: ShaderSource, pub source: ShaderSource,
pub config: ShaderPassConfig, pub meta: ShaderPassMeta,
pub uniform_storage: D3D9UniformStorage, pub uniform_storage: D3D9UniformStorage,
pub gl_halfpixel: Option<RegisterAssignment>, pub gl_halfpixel: Option<RegisterAssignment>,
} }
@ -38,8 +38,8 @@ impl FilterPassMeta for FilterPass {
self.source.format self.source.format
} }
fn config(&self) -> &ShaderPassConfig { fn meta(&self) -> &ShaderPassMeta {
&self.config &self.meta
} }
} }
@ -150,7 +150,7 @@ impl FilterPass {
output: RenderTarget<IDirect3DSurface9>, output: RenderTarget<IDirect3DSurface9>,
vbo_type: QuadType, vbo_type: QuadType,
) -> error::Result<()> { ) -> error::Result<()> {
if self.config.mipmap_input && !parent.disable_mipmaps { if self.meta.mipmap_input && !parent.disable_mipmaps {
unsafe { unsafe {
source.handle.GenerateMipSubLevels(); source.handle.GenerateMipSubLevels();
} }

View file

@ -147,10 +147,10 @@ impl<T: GLInterface> FilterChainImpl<T> {
// initialize passes // initialize passes
let filters = Self::init_passes(&context, version, passes, &semantics, disable_cache)?; let filters = Self::init_passes(&context, version, passes, &semantics, disable_cache)?;
let default_filter = filters.first().map(|f| f.config.filter).unwrap_or_default(); let default_filter = filters.first().map(|f| f.meta.filter).unwrap_or_default();
let default_wrap = filters let default_wrap = filters
.first() .first()
.map(|f| f.config.wrap_mode) .map(|f| f.meta.wrap_mode)
.unwrap_or_default(); .unwrap_or_default();
let samplers = SamplerSet::new(&context)?; let samplers = SamplerSet::new(&context)?;
@ -256,7 +256,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
uniform_storage, uniform_storage,
uniform_bindings, uniform_bindings,
source, source,
config, meta: config,
}); });
} }
@ -309,8 +309,8 @@ impl<T: GLInterface> FilterChainImpl<T> {
self.draw_quad self.draw_quad
.bind_vertices(&self.common.context, QuadType::Offscreen); .bind_vertices(&self.common.context, QuadType::Offscreen);
let filter = passes[0].config.filter; let filter = passes[0].meta.filter;
let wrap_mode = passes[0].config.wrap_mode; let wrap_mode = passes[0].meta.wrap_mode;
// update history // update history
for (texture, fbo) in self for (texture, fbo) in self
@ -352,9 +352,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
.zip(self.feedback_framebuffers.iter()) .zip(self.feedback_framebuffers.iter())
.zip(passes.iter()) .zip(passes.iter())
{ {
texture.image = fbo texture.image = fbo.as_texture(pass.meta.filter, pass.meta.wrap_mode).image;
.as_texture(pass.config.filter, pass.config.wrap_mode)
.image;
} }
let passes_len = passes.len(); let passes_len = passes.len();
@ -364,14 +362,14 @@ impl<T: GLInterface> FilterChainImpl<T> {
.bind_vertices(&self.common.context, QuadType::Offscreen); .bind_vertices(&self.common.context, QuadType::Offscreen);
for (index, pass) in pass.iter_mut().enumerate() { for (index, pass) in pass.iter_mut().enumerate() {
let target = &self.output_framebuffers[index]; let target = &self.output_framebuffers[index];
source.filter = pass.config.filter; source.filter = pass.meta.filter;
source.mip_filter = pass.config.filter; source.mip_filter = pass.meta.filter;
source.wrap_mode = pass.config.wrap_mode; source.wrap_mode = pass.meta.wrap_mode;
pass.draw( pass.draw(
index, index,
&self.common, &self.common,
pass.config.get_frame_count(frame_count), pass.meta.get_frame_count(frame_count),
options, options,
viewport, viewport,
&original, &original,
@ -379,7 +377,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
RenderTarget::identity(target)?, RenderTarget::identity(target)?,
)?; )?;
let target = target.as_texture(pass.config.filter, pass.config.wrap_mode); let target = target.as_texture(pass.meta.filter, pass.meta.wrap_mode);
self.common.output_textures[index] = target; self.common.output_textures[index] = target;
source = target; source = target;
} }
@ -394,16 +392,16 @@ impl<T: GLInterface> FilterChainImpl<T> {
.render_target .render_target
.ensure::<T::FramebufferInterface>(viewport.output)?; .ensure::<T::FramebufferInterface>(viewport.output)?;
source.filter = pass.config.filter; source.filter = pass.meta.filter;
source.mip_filter = pass.config.filter; source.mip_filter = pass.meta.filter;
source.wrap_mode = pass.config.wrap_mode; source.wrap_mode = pass.meta.wrap_mode;
if self.draw_last_pass_feedback { if self.draw_last_pass_feedback {
let target = &self.output_framebuffers[index]; let target = &self.output_framebuffers[index];
pass.draw( pass.draw(
index, index,
&self.common, &self.common,
pass.config.get_frame_count(frame_count), pass.meta.get_frame_count(frame_count),
options, options,
viewport, viewport,
&original, &original,
@ -415,7 +413,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
pass.draw( pass.draw(
index, index,
&self.common, &self.common,
pass.config.get_frame_count(frame_count), pass.meta.get_frame_count(frame_count),
options, options,
viewport, viewport,
&original, &original,
@ -424,7 +422,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
)?; )?;
self.common.output_textures[passes_len - 1] = viewport self.common.output_textures[passes_len - 1] = viewport
.output .output
.as_texture(pass.config.filter, pass.config.wrap_mode); .as_texture(pass.meta.filter, pass.meta.wrap_mode);
} }
// swap feedback framebuffers with output // swap feedback framebuffers with output

View file

@ -4,7 +4,7 @@ use librashader_reflect::reflect::ShaderReflection;
use librashader_common::map::FastHashMap; use librashader_common::map::FastHashMap;
use librashader_common::{ImageFormat, Size, Viewport}; use librashader_common::{ImageFormat, Size, Viewport};
use librashader_preprocess::ShaderSource; use librashader_preprocess::ShaderSource;
use librashader_presets::ShaderPassConfig; use librashader_presets::ShaderPassMeta;
use librashader_reflect::reflect::semantics::{MemberOffset, TextureBinding, UniformBinding}; use librashader_reflect::reflect::semantics::{MemberOffset, TextureBinding, UniformBinding};
use librashader_runtime::binding::{BindSemantics, ContextOffset, TextureInput, UniformInputs}; use librashader_runtime::binding::{BindSemantics, ContextOffset, TextureInput, UniformInputs};
use librashader_runtime::filter_pass::FilterPassMeta; use librashader_runtime::filter_pass::FilterPassMeta;
@ -38,7 +38,7 @@ pub(crate) struct FilterPass<T: GLInterface> {
pub(crate) uniform_storage: GlUniformStorage, pub(crate) uniform_storage: GlUniformStorage,
pub uniform_bindings: FastHashMap<UniformBinding, UniformOffset>, pub uniform_bindings: FastHashMap<UniformBinding, UniformOffset>,
pub source: ShaderSource, pub source: ShaderSource,
pub config: ShaderPassConfig, pub meta: ShaderPassMeta,
} }
impl TextureInput for InputTexture { impl TextureInput for InputTexture {
@ -89,7 +89,7 @@ impl<T: GLInterface> FilterPass<T> {
) -> error::Result<()> { ) -> error::Result<()> {
let framebuffer = output.output; let framebuffer = output.output;
if self.config.mipmap_input && !parent.disable_mipmaps { if self.meta.mipmap_input && !parent.disable_mipmaps {
T::BindTexture::gen_mipmaps(&parent.context, source); T::BindTexture::gen_mipmaps(&parent.context, source);
} }
@ -162,8 +162,8 @@ impl<T: GLInterface> FilterPassMeta for FilterPass<T> {
self.source.format self.source.format
} }
fn config(&self) -> &ShaderPassConfig { fn meta(&self) -> &ShaderPassMeta {
&self.config &self.meta
} }
} }

View file

@ -205,7 +205,7 @@ impl FilterChainMetal {
uniform_storage, uniform_storage,
uniform_bindings, uniform_bindings,
source, source,
config, meta: config,
graphics_pipeline, graphics_pipeline,
}) })
}) })
@ -379,8 +379,8 @@ impl FilterChainMetal {
return Ok(()); return Ok(());
} }
let filter = passes[0].config.filter; let filter = passes[0].meta.filter;
let wrap_mode = passes[0].config.wrap_mode; let wrap_mode = passes[0].meta.wrap_mode;
// update history // update history
for (texture, image) in self for (texture, image) in self
@ -428,9 +428,9 @@ impl FilterChainMetal {
feedback: &OwnedTexture| { feedback: &OwnedTexture| {
// refresh inputs // refresh inputs
self.common.feedback_textures[index] = self.common.feedback_textures[index] =
Some(feedback.as_input(pass.config.filter, pass.config.wrap_mode)?); Some(feedback.as_input(pass.meta.filter, pass.meta.wrap_mode)?);
self.common.output_textures[index] = self.common.output_textures[index] =
Some(output.as_input(pass.config.filter, pass.config.wrap_mode)?); Some(output.as_input(pass.meta.filter, pass.meta.wrap_mode)?);
Ok(()) Ok(())
}), }),
)?; )?;
@ -441,16 +441,16 @@ impl FilterChainMetal {
for (index, pass) in pass.iter_mut().enumerate() { for (index, pass) in pass.iter_mut().enumerate() {
let target = &self.output_framebuffers[index]; let target = &self.output_framebuffers[index];
source.filter_mode = pass.config.filter; source.filter_mode = pass.meta.filter;
source.wrap_mode = pass.config.wrap_mode; source.wrap_mode = pass.meta.wrap_mode;
source.mip_filter = pass.config.filter; source.mip_filter = pass.meta.filter;
let out = RenderTarget::identity(target.texture.as_ref())?; let out = RenderTarget::identity(target.texture.as_ref())?;
pass.draw( pass.draw(
&cmd, &cmd,
index, index,
&self.common, &self.common,
pass.config.get_frame_count(frame_count), pass.meta.get_frame_count(frame_count),
options, options,
viewport, viewport,
&original, &original,
@ -464,7 +464,7 @@ impl FilterChainMetal {
} }
self.common.output_textures[index] = self.common.output_textures[index] =
Some(target.as_input(pass.config.filter, pass.config.wrap_mode)?); Some(target.as_input(pass.meta.filter, pass.meta.wrap_mode)?);
source = self.common.output_textures[index] source = self.common.output_textures[index]
.as_ref() .as_ref()
.map(InputTexture::try_clone) .map(InputTexture::try_clone)
@ -484,9 +484,9 @@ impl FilterChainMetal {
.recompile(&self.common.device, viewport.output.pixelFormat())?; .recompile(&self.common.device, viewport.output.pixelFormat())?;
} }
source.filter_mode = pass.config.filter; source.filter_mode = pass.meta.filter;
source.wrap_mode = pass.config.wrap_mode; source.wrap_mode = pass.meta.wrap_mode;
source.mip_filter = pass.config.filter; source.mip_filter = pass.meta.filter;
let index = passes_len - 1; let index = passes_len - 1;
if self.draw_last_pass_feedback { if self.draw_last_pass_feedback {
@ -496,7 +496,7 @@ impl FilterChainMetal {
&cmd, &cmd,
passes_len - 1, passes_len - 1,
&self.common, &self.common,
pass.config.get_frame_count(frame_count), pass.meta.get_frame_count(frame_count),
options, options,
viewport, viewport,
&original, &original,
@ -511,7 +511,7 @@ impl FilterChainMetal {
&cmd, &cmd,
index, index,
&self.common, &self.common,
pass.config.get_frame_count(frame_count), pass.meta.get_frame_count(frame_count),
options, options,
viewport, viewport,
&original, &original,

View file

@ -8,7 +8,7 @@ use crate::texture::{get_texture_size, InputTexture};
use librashader_common::map::FastHashMap; use librashader_common::map::FastHashMap;
use librashader_common::{ImageFormat, Size, Viewport}; use librashader_common::{ImageFormat, Size, Viewport};
use librashader_preprocess::ShaderSource; use librashader_preprocess::ShaderSource;
use librashader_presets::ShaderPassConfig; use librashader_presets::ShaderPassMeta;
use librashader_reflect::reflect::semantics::{MemberOffset, TextureBinding, UniformBinding}; use librashader_reflect::reflect::semantics::{MemberOffset, TextureBinding, UniformBinding};
use librashader_reflect::reflect::ShaderReflection; use librashader_reflect::reflect::ShaderReflection;
use librashader_runtime::binding::{BindSemantics, TextureInput, UniformInputs}; use librashader_runtime::binding::{BindSemantics, TextureInput, UniformInputs};
@ -55,7 +55,7 @@ pub struct FilterPass {
UniformStorage<NoUniformBinder, Option<()>, MetalBuffer, MetalBuffer>, UniformStorage<NoUniformBinder, Option<()>, MetalBuffer, MetalBuffer>,
pub uniform_bindings: FastHashMap<UniformBinding, MemberOffset>, pub uniform_bindings: FastHashMap<UniformBinding, MemberOffset>,
pub source: ShaderSource, pub source: ShaderSource,
pub config: ShaderPassConfig, pub meta: ShaderPassMeta,
pub graphics_pipeline: MetalGraphicsPipeline, pub graphics_pipeline: MetalGraphicsPipeline,
} }
@ -177,7 +177,7 @@ impl FilterPassMeta for FilterPass {
self.source.format self.source.format
} }
fn config(&self) -> &ShaderPassConfig { fn meta(&self) -> &ShaderPassMeta {
&self.config &self.meta
} }
} }

View file

@ -511,7 +511,7 @@ impl FilterChainVulkan {
uniform_storage, uniform_storage,
uniform_bindings, uniform_bindings,
source, source,
config, meta: config,
graphics_pipeline, graphics_pipeline,
// ubo_ring, // ubo_ring,
frames_in_flight, frames_in_flight,
@ -654,8 +654,8 @@ impl FilterChainVulkan {
self.vulkan.device.create_image_view(&create_info, None)? self.vulkan.device.create_image_view(&create_info, None)?
}; };
let filter = passes[0].config.filter; let filter = passes[0].meta.filter;
let wrap_mode = passes[0].config.wrap_mode; let wrap_mode = passes[0].meta.wrap_mode;
// update history // update history
for (texture, image) in self for (texture, image) in self
@ -704,9 +704,9 @@ impl FilterChainVulkan {
feedback: &OwnedImage| { feedback: &OwnedImage| {
// refresh inputs // refresh inputs
self.common.feedback_textures[index] = self.common.feedback_textures[index] =
Some(feedback.as_input(pass.config.filter, pass.config.wrap_mode)); Some(feedback.as_input(pass.meta.filter, pass.meta.wrap_mode));
self.common.output_textures[index] = self.common.output_textures[index] =
Some(output.as_input(pass.config.filter, pass.config.wrap_mode)); Some(output.as_input(pass.meta.filter, pass.meta.wrap_mode));
Ok(()) Ok(())
}), }),
)?; )?;
@ -721,9 +721,9 @@ impl FilterChainVulkan {
.bind_vbo_for_frame(&self.vulkan.device, cmd); .bind_vbo_for_frame(&self.vulkan.device, cmd);
for (index, pass) in pass.iter_mut().enumerate() { for (index, pass) in pass.iter_mut().enumerate() {
let target = &self.output_framebuffers[index]; let target = &self.output_framebuffers[index];
source.filter_mode = pass.config.filter; source.filter_mode = pass.meta.filter;
source.wrap_mode = pass.config.wrap_mode; source.wrap_mode = pass.meta.wrap_mode;
source.mip_filter = pass.config.filter; source.mip_filter = pass.meta.filter;
let output_image = OutputImage::new(&self.vulkan.device, target.image.clone())?; let output_image = OutputImage::new(&self.vulkan.device, target.image.clone())?;
let out = RenderTarget::identity(&output_image)?; let out = RenderTarget::identity(&output_image)?;
@ -733,7 +733,7 @@ impl FilterChainVulkan {
target.image.format, target.image.format,
index, index,
&self.common, &self.common,
pass.config.get_frame_count(frame_count), pass.meta.get_frame_count(frame_count),
options, options,
viewport, viewport,
&original, &original,
@ -768,9 +768,9 @@ impl FilterChainVulkan {
pass.graphics_pipeline.recompile(viewport.output.format)?; pass.graphics_pipeline.recompile(viewport.output.format)?;
} }
source.filter_mode = pass.config.filter; source.filter_mode = pass.meta.filter;
source.wrap_mode = pass.config.wrap_mode; source.wrap_mode = pass.meta.wrap_mode;
source.mip_filter = pass.config.filter; source.mip_filter = pass.meta.filter;
if self.draw_last_pass_feedback { if self.draw_last_pass_feedback {
let target = &self.output_framebuffers[index]; let target = &self.output_framebuffers[index];
@ -783,7 +783,7 @@ impl FilterChainVulkan {
target.image.format, target.image.format,
index, index,
&self.common, &self.common,
pass.config.get_frame_count(frame_count), pass.meta.get_frame_count(frame_count),
options, options,
viewport, viewport,
&original, &original,
@ -805,7 +805,7 @@ impl FilterChainVulkan {
viewport.output.format, viewport.output.format,
index, index,
&self.common, &self.common,
pass.config.get_frame_count(frame_count), pass.meta.get_frame_count(frame_count),
options, options,
viewport, viewport,
&original, &original,

View file

@ -10,7 +10,7 @@ use ash::vk;
use librashader_common::map::FastHashMap; use librashader_common::map::FastHashMap;
use librashader_common::{ImageFormat, Size, Viewport}; use librashader_common::{ImageFormat, Size, Viewport};
use librashader_preprocess::ShaderSource; use librashader_preprocess::ShaderSource;
use librashader_presets::ShaderPassConfig; use librashader_presets::ShaderPassMeta;
use librashader_reflect::reflect::semantics::{ use librashader_reflect::reflect::semantics::{
BindingStage, MemberOffset, TextureBinding, UniformBinding, BindingStage, MemberOffset, TextureBinding, UniformBinding,
}; };
@ -28,7 +28,7 @@ pub struct FilterPass {
UniformStorage<NoUniformBinder, Option<()>, RawVulkanBuffer, Box<[u8]>, Arc<ash::Device>>, UniformStorage<NoUniformBinder, Option<()>, RawVulkanBuffer, Box<[u8]>, Arc<ash::Device>>,
pub uniform_bindings: FastHashMap<UniformBinding, MemberOffset>, pub uniform_bindings: FastHashMap<UniformBinding, MemberOffset>,
pub source: ShaderSource, pub source: ShaderSource,
pub config: ShaderPassConfig, pub meta: ShaderPassMeta,
pub graphics_pipeline: VulkanGraphicsPipeline, pub graphics_pipeline: VulkanGraphicsPipeline,
pub frames_in_flight: u32, pub frames_in_flight: u32,
} }
@ -78,8 +78,8 @@ impl FilterPassMeta for FilterPass {
self.source.format self.source.format
} }
fn config(&self) -> &ShaderPassConfig { fn meta(&self) -> &ShaderPassMeta {
&self.config &self.meta
} }
} }

View file

@ -336,7 +336,7 @@ impl FilterChainWgpu {
uniform_storage, uniform_storage,
uniform_bindings, uniform_bindings,
source, source,
config, meta: config,
graphics_pipeline, graphics_pipeline,
}) })
}) })
@ -389,8 +389,8 @@ impl FilterChainWgpu {
let original_image_view = input.create_view(&wgpu::TextureViewDescriptor::default()); let original_image_view = input.create_view(&wgpu::TextureViewDescriptor::default());
let filter = passes[0].config.filter; let filter = passes[0].meta.filter;
let wrap_mode = passes[0].config.wrap_mode; let wrap_mode = passes[0].meta.wrap_mode;
// update history // update history
for (texture, image) in self for (texture, image) in self
@ -433,9 +433,9 @@ impl FilterChainWgpu {
feedback: &OwnedImage| { feedback: &OwnedImage| {
// refresh inputs // refresh inputs
self.common.feedback_textures[index] = self.common.feedback_textures[index] =
Some(feedback.as_input(pass.config.filter, pass.config.wrap_mode)); Some(feedback.as_input(pass.meta.filter, pass.meta.wrap_mode));
self.common.output_textures[index] = self.common.output_textures[index] =
Some(output.as_input(pass.config.filter, pass.config.wrap_mode)); Some(output.as_input(pass.meta.filter, pass.meta.wrap_mode));
Ok(()) Ok(())
}), }),
)?; )?;
@ -446,9 +446,9 @@ impl FilterChainWgpu {
let options = options.unwrap_or(&self.default_frame_options); let options = options.unwrap_or(&self.default_frame_options);
for (index, pass) in pass.iter_mut().enumerate() { for (index, pass) in pass.iter_mut().enumerate() {
source.filter_mode = pass.config.filter; source.filter_mode = pass.meta.filter;
source.wrap_mode = pass.config.wrap_mode; source.wrap_mode = pass.meta.wrap_mode;
source.mip_filter = pass.config.filter; source.mip_filter = pass.meta.filter;
let target = &self.output_framebuffers[index]; let target = &self.output_framebuffers[index];
let output_image = WgpuOutputView::from(target); let output_image = WgpuOutputView::from(target);
@ -458,7 +458,7 @@ impl FilterChainWgpu {
cmd, cmd,
index, index,
&self.common, &self.common,
pass.config.get_frame_count(frame_count), pass.meta.get_frame_count(frame_count),
options, options,
viewport, viewport,
&original, &original,
@ -490,9 +490,9 @@ impl FilterChainWgpu {
pass.graphics_pipeline.recompile(viewport.output.format); pass.graphics_pipeline.recompile(viewport.output.format);
} }
source.filter_mode = pass.config.filter; source.filter_mode = pass.meta.filter;
source.wrap_mode = pass.config.wrap_mode; source.wrap_mode = pass.meta.wrap_mode;
source.mip_filter = pass.config.filter; source.mip_filter = pass.meta.filter;
if self.draw_last_pass_feedback { if self.draw_last_pass_feedback {
let target = &self.output_framebuffers[index]; let target = &self.output_framebuffers[index];
@ -503,7 +503,7 @@ impl FilterChainWgpu {
cmd, cmd,
index, index,
&self.common, &self.common,
pass.config.get_frame_count(frame_count), pass.meta.get_frame_count(frame_count),
options, options,
viewport, viewport,
&original, &original,
@ -518,7 +518,7 @@ impl FilterChainWgpu {
cmd, cmd,
index, index,
&self.common, &self.common,
pass.config.get_frame_count(frame_count), pass.meta.get_frame_count(frame_count),
options, options,
viewport, viewport,
&original, &original,

View file

@ -9,7 +9,7 @@ use crate::texture::InputImage;
use librashader_common::map::FastHashMap; use librashader_common::map::FastHashMap;
use librashader_common::{ImageFormat, Size, Viewport}; use librashader_common::{ImageFormat, Size, Viewport};
use librashader_preprocess::ShaderSource; use librashader_preprocess::ShaderSource;
use librashader_presets::ShaderPassConfig; use librashader_presets::ShaderPassMeta;
use librashader_reflect::reflect::semantics::{ use librashader_reflect::reflect::semantics::{
BindingStage, MemberOffset, TextureBinding, UniformBinding, BindingStage, MemberOffset, TextureBinding, UniformBinding,
}; };
@ -34,7 +34,7 @@ pub struct FilterPass {
>, >,
pub uniform_bindings: FastHashMap<UniformBinding, MemberOffset>, pub uniform_bindings: FastHashMap<UniformBinding, MemberOffset>,
pub source: ShaderSource, pub source: ShaderSource,
pub config: ShaderPassConfig, pub meta: ShaderPassMeta,
pub graphics_pipeline: WgpuGraphicsPipeline, pub graphics_pipeline: WgpuGraphicsPipeline,
} }
@ -255,7 +255,7 @@ impl FilterPassMeta for FilterPass {
self.source.format self.source.format
} }
fn config(&self) -> &ShaderPassConfig { fn meta(&self) -> &ShaderPassMeta {
&self.config &self.meta
} }
} }

View file

@ -1,5 +1,5 @@
use librashader_common::ImageFormat; use librashader_common::ImageFormat;
use librashader_presets::ShaderPassConfig; use librashader_presets::ShaderPassMeta;
/// Trait for metadata about a filter pass. /// Trait for metadata about a filter pass.
pub trait FilterPassMeta { pub trait FilterPassMeta {
@ -7,13 +7,13 @@ pub trait FilterPassMeta {
fn framebuffer_format(&self) -> ImageFormat; fn framebuffer_format(&self) -> ImageFormat;
/// Gets a reference to the filter pass config. /// Gets a reference to the filter pass config.
fn config(&self) -> &ShaderPassConfig; fn meta(&self) -> &ShaderPassMeta;
/// Gets the format of the filter pass framebuffer. /// Gets the format of the filter pass framebuffer.
#[inline(always)] #[inline(always)]
fn get_format(&self) -> ImageFormat { fn get_format(&self) -> ImageFormat {
let fb_format = self.framebuffer_format(); let fb_format = self.framebuffer_format();
if let Some(format) = self.config().get_format_override() { if let Some(format) = self.meta().get_format_override() {
format format
} else if fb_format == ImageFormat::Unknown { } else if fb_format == ImageFormat::Unknown {
ImageFormat::R8G8B8A8Unorm ImageFormat::R8G8B8A8Unorm

View file

@ -212,10 +212,10 @@ where
while let Some((index, pass)) = iterator.next() { while let Some((index, pass)) = iterator.next() {
let should_mipmap = iterator let should_mipmap = iterator
.peek() .peek()
.map_or(false, |(_, p)| p.config().mipmap_input); .map_or(false, |(_, p)| p.meta().mipmap_input);
let next_size = output[index].scale( let next_size = output[index].scale(
pass.config().scaling.clone(), pass.meta().scaling.clone(),
pass.get_format(), pass.get_format(),
&viewport_size, &viewport_size,
&target_size, &target_size,
@ -225,7 +225,7 @@ where
)?; )?;
feedback[index].scale( feedback[index].scale(
pass.config().scaling.clone(), pass.meta().scaling.clone(),
pass.get_format(), pass.get_format(),
&viewport_size, &viewport_size,
&target_size, &target_size,