diff --git a/Cargo.toml b/Cargo.toml index dbcab1b..5743d54 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,8 +16,7 @@ members = [ "librashader-cache", "librashader-capi", "librashader-build-script", - "librashader-cli" -] + "librashader-cli"] resolver = "2" [workspace.dependencies] diff --git a/librashader-capi/src/runtime/vk/filter_chain.rs b/librashader-capi/src/runtime/vk/filter_chain.rs index 55705f0..e8e7b09 100644 --- a/librashader-capi/src/runtime/vk/filter_chain.rs +++ b/librashader-capi/src/runtime/vk/filter_chain.rs @@ -6,8 +6,8 @@ use crate::ffi::extern_fn; use librashader::runtime::vk::{ FilterChain, FilterChainOptions, FrameOptions, VulkanImage, VulkanInstance, }; -use std::ffi::CStr; use std::ffi::c_char; +use std::ffi::CStr; use std::mem::MaybeUninit; use std::ptr::NonNull; use std::slice; diff --git a/librashader-presets/src/parse/preset.rs b/librashader-presets/src/parse/preset.rs index 25c7d3d..10c93e3 100644 --- a/librashader-presets/src/parse/preset.rs +++ b/librashader-presets/src/parse/preset.rs @@ -1,6 +1,9 @@ use crate::parse::remove_if; 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; pub fn resolve_values(mut values: Vec) -> ShaderPreset { @@ -114,63 +117,65 @@ pub fn resolve_values(mut values: Vec) -> ShaderPreset { } let shader = ShaderPassConfig { - id, name, - alias: shader_values.iter().find_map(|f| match f { - Value::Alias(_, value) => Some(value.clone()), - _ => None, - }), - filter: shader_values - .iter() - .find_map(|f| match f { - Value::FilterMode(_, value) => Some(*value), + meta: ShaderPassMeta { + id, + alias: shader_values.iter().find_map(|f| match f { + Value::Alias(_, value) => Some(value.clone()), _ => None, - }) - .unwrap_or_default(), - wrap_mode: shader_values - .iter() - .find_map(|f| match f { - Value::WrapMode(_, value) => Some(*value), - _ => None, - }) - .unwrap_or_default(), - frame_count_mod: shader_values - .iter() - .find_map(|f| match f { - Value::FrameCountMod(_, value) => Some(*value), - _ => None, - }) - .unwrap_or(0), - srgb_framebuffer: shader_values - .iter() - .find_map(|f| match f { - Value::SrgbFramebuffer(_, value) => Some(*value), - _ => None, - }) - .unwrap_or(false), - float_framebuffer: shader_values - .iter() - .find_map(|f| match f { - Value::FloatFramebuffer(_, value) => Some(*value), - _ => None, - }) - .unwrap_or(false), - mipmap_input: shader_values - .iter() - .find_map(|f| match f { - Value::MipmapInput(_, value) => Some(*value), - _ => None, - }) - .unwrap_or(false), - scaling: Scale2D { - valid: scale_valid, - 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(), + }), + filter: shader_values + .iter() + .find_map(|f| match f { + Value::FilterMode(_, value) => Some(*value), + _ => None, + }) + .unwrap_or_default(), + wrap_mode: shader_values + .iter() + .find_map(|f| match f { + Value::WrapMode(_, value) => Some(*value), + _ => None, + }) + .unwrap_or_default(), + frame_count_mod: shader_values + .iter() + .find_map(|f| match f { + Value::FrameCountMod(_, value) => Some(*value), + _ => None, + }) + .unwrap_or(0), + srgb_framebuffer: shader_values + .iter() + .find_map(|f| match f { + Value::SrgbFramebuffer(_, value) => Some(*value), + _ => None, + }) + .unwrap_or(false), + float_framebuffer: shader_values + .iter() + .find_map(|f| match f { + Value::FloatFramebuffer(_, value) => Some(*value), + _ => None, + }) + .unwrap_or(false), + mipmap_input: shader_values + .iter() + .find_map(|f| match f { + Value::MipmapInput(_, value) => Some(*value), + _ => None, + }) + .unwrap_or(false), + scaling: Scale2D { + valid: scale_valid, + 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(), + }, }, }, }; diff --git a/librashader-presets/src/preset.rs b/librashader-presets/src/preset.rs index 09fcb76..261fe2d 100644 --- a/librashader-presets/src/preset.rs +++ b/librashader-presets/src/preset.rs @@ -9,10 +9,17 @@ use std::str::FromStr; #[derive(Debug, Clone)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] 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. 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. pub alias: Option, /// The filtering mode that this shader pass should expect. @@ -31,7 +38,7 @@ pub struct ShaderPassConfig { pub scaling: Scale2D, } -impl ShaderPassConfig { +impl ShaderPassMeta { /// If the framebuffer expects a different format than what was defined in the /// shader source, returns such format. #[inline(always)] diff --git a/librashader-reflect/src/reflect/presets.rs b/librashader-reflect/src/reflect/presets.rs index eee1a56..441da0a 100644 --- a/librashader-reflect/src/reflect/presets.rs +++ b/librashader-reflect/src/reflect/presets.rs @@ -7,7 +7,7 @@ use crate::reflect::semantics::{ }; use librashader_common::map::{FastHashMap, ShortString}; 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. /// @@ -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. -pub type ShaderPassArtifact = (ShaderPassConfig, ShaderSource, CompilerBackend); +pub type ShaderPassArtifact = (ShaderPassMeta, ShaderSource, CompilerBackend); impl CompilePresetTarget for T {} @@ -101,22 +101,22 @@ where }), ); } - Ok::<_, E>((shader, source, reflect)) + Ok::<_, E>((shader.meta, source, reflect)) }) - .collect::)>, E>>()?; + .collect::)>, E>>()?; - for (config, source, _) in &passes { + for (meta, source, _) in &passes { insert_pass_semantics( &mut uniform_semantics, &mut texture_semantics, - config.alias.as_ref(), - config.id as usize, + meta.alias.as_ref(), + meta.id as usize, ); insert_pass_semantics( &mut uniform_semantics, &mut texture_semantics, source.name.as_ref(), - config.id as usize, + meta.id as usize, ); } @@ -251,14 +251,14 @@ impl ShaderSemantics { insert_pass_semantics( &mut uniform_semantics, &mut texture_semantics, - config.alias.as_ref(), - config.id as usize, + config.meta.alias.as_ref(), + config.meta.id as usize, ); insert_pass_semantics( &mut uniform_semantics, &mut texture_semantics, source.name.as_ref(), - config.id as usize, + config.meta.id as usize, ); insert_lut_semantics( preset.textures.as_slice(), diff --git a/librashader-runtime-d3d11/src/filter_chain.rs b/librashader-runtime-d3d11/src/filter_chain.rs index 2660d42..7878827 100644 --- a/librashader-runtime-d3d11/src/filter_chain.rs +++ b/librashader-runtime-d3d11/src/filter_chain.rs @@ -328,7 +328,7 @@ impl FilterChainD3D11 { uniform_buffer: ubo_cbuffer, push_buffer: push_cbuffer, source, - config, + meta: config, }) }; @@ -425,8 +425,8 @@ impl FilterChainD3D11 { } let options = options.unwrap_or(&self.default_options); - let filter = passes[0].config.filter; - let wrap_mode = passes[0].config.wrap_mode; + let filter = passes[0].meta.filter; + let wrap_mode = passes[0].meta.wrap_mode; for (texture, fbo) in self .common @@ -467,8 +467,8 @@ impl FilterChainD3D11 { { *texture = Some(InputTexture::from_framebuffer( fbo, - pass.config.wrap_mode, - pass.config.filter, + pass.meta.wrap_mode, + pass.meta.filter, )?); } @@ -479,14 +479,14 @@ impl FilterChainD3D11 { self.common.draw_quad.bind_vbo_for_frame(ctx); for (index, pass) in pass.iter_mut().enumerate() { - source.filter = pass.config.filter; - source.wrap_mode = pass.config.wrap_mode; + source.filter = pass.meta.filter; + source.wrap_mode = pass.meta.wrap_mode; let target = &self.output_framebuffers[index]; pass.draw( ctx, index, &self.common, - pass.config.get_frame_count(frame_count), + pass.meta.get_frame_count(frame_count), options, viewport, &original, @@ -497,8 +497,8 @@ impl FilterChainD3D11 { source = InputTexture { view: target.create_shader_resource_view()?, - filter: pass.config.filter, - wrap_mode: pass.config.wrap_mode, + filter: pass.meta.filter, + wrap_mode: pass.meta.wrap_mode, }; self.common.output_textures[index] = Some(source.clone()); } @@ -507,8 +507,8 @@ impl FilterChainD3D11 { assert_eq!(last.len(), 1); if let Some(pass) = last.iter_mut().next() { let index = passes_len - 1; - source.filter = pass.config.filter; - source.wrap_mode = pass.config.wrap_mode; + source.filter = pass.meta.filter; + source.wrap_mode = pass.meta.wrap_mode; // Draw to output_framebuffers for proper handling of feedback. @@ -518,7 +518,7 @@ impl FilterChainD3D11 { &ctx, index, &self.common, - pass.config.get_frame_count(frame_count), + pass.meta.get_frame_count(frame_count), options, viewport, &original, @@ -535,7 +535,7 @@ impl FilterChainD3D11 { &ctx, index, &self.common, - pass.config.get_frame_count(frame_count), + pass.meta.get_frame_count(frame_count), options, viewport, &original, diff --git a/librashader-runtime-d3d11/src/filter_pass.rs b/librashader-runtime-d3d11/src/filter_pass.rs index 20bebe6..bbd5f5e 100644 --- a/librashader-runtime-d3d11/src/filter_pass.rs +++ b/librashader-runtime-d3d11/src/filter_pass.rs @@ -6,7 +6,7 @@ use windows::Win32::Foundation::RECT; use librashader_common::map::FastHashMap; use librashader_common::{ImageFormat, Size, Viewport}; use librashader_preprocess::ShaderSource; -use librashader_presets::ShaderPassConfig; +use librashader_presets::ShaderPassMeta; use librashader_reflect::reflect::semantics::{ BindingStage, MemberOffset, TextureBinding, UniformBinding, }; @@ -47,7 +47,7 @@ pub struct FilterPass { pub uniform_buffer: Option, pub push_buffer: Option, pub source: ShaderSource, - pub config: ShaderPassConfig, + pub meta: ShaderPassMeta, } // 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 } - fn config(&self) -> &ShaderPassConfig { - &self.config + fn meta(&self) -> &ShaderPassMeta { + &self.meta } } @@ -157,7 +157,7 @@ impl FilterPass { output: RenderTarget, vbo_type: QuadType, ) -> error::Result<()> { - if self.config.mipmap_input && !parent.disable_mipmaps { + if self.meta.mipmap_input && !parent.disable_mipmaps { unsafe { ctx.GenerateMips(&source.view); } diff --git a/librashader-runtime-d3d12/src/filter_chain.rs b/librashader-runtime-d3d12/src/filter_chain.rs index 8aea2fa..ca96a8d 100644 --- a/librashader-runtime-d3d12/src/filter_chain.rs +++ b/librashader-runtime-d3d12/src/filter_chain.rs @@ -619,7 +619,7 @@ impl FilterChainD3D12 { uniform_bindings, uniform_storage, pipeline: graphics_pipeline, - config, + meta: config, texture_heap, sampler_heap, source, @@ -708,8 +708,8 @@ impl FilterChainD3D12 { let options = options.unwrap_or(&self.default_options); - let filter = passes[0].config.filter; - let wrap_mode = passes[0].config.wrap_mode; + let filter = passes[0].meta.filter; + let wrap_mode = passes[0].meta.wrap_mode; for ((texture, fbo), pass) in self .common @@ -720,8 +720,8 @@ impl FilterChainD3D12 { { *texture = Some(fbo.create_shader_resource_view( &mut self.staging_heap, - pass.config.filter, - pass.config.wrap_mode, + pass.meta.filter, + pass.meta.wrap_mode, )?); } @@ -771,13 +771,13 @@ impl FilterChainD3D12 { // refresh inputs self.common.feedback_textures[index] = Some(feedback.create_shader_resource_view( &mut self.staging_heap, - pass.config.filter, - pass.config.wrap_mode, + pass.meta.filter, + pass.meta.wrap_mode, )?); self.common.output_textures[index] = Some(output.create_shader_resource_view( &mut self.staging_heap, - pass.config.filter, - pass.config.wrap_mode, + pass.meta.filter, + pass.meta.wrap_mode, )?); Ok(()) @@ -800,8 +800,8 @@ impl FilterChainD3D12 { self.common.draw_quad.bind_vertices_for_frame(cmd); for (index, pass) in pass.iter_mut().enumerate() { - source.filter = pass.config.filter; - source.wrap_mode = pass.config.wrap_mode; + source.filter = pass.meta.filter; + source.wrap_mode = pass.meta.wrap_mode; let target = &self.output_framebuffers[index]; @@ -828,7 +828,7 @@ impl FilterChainD3D12 { cmd, index, &self.common, - pass.config.get_frame_count(frame_count), + pass.meta.get_frame_count(frame_count), options, viewport, &original, @@ -872,8 +872,8 @@ impl FilterChainD3D12 { if let Some(pass) = last.iter_mut().next() { let index = passes_len - 1; - source.filter = pass.config.filter; - source.wrap_mode = pass.config.wrap_mode; + source.filter = pass.meta.filter; + source.wrap_mode = pass.meta.wrap_mode; if self.draw_last_pass_feedback { let feedback_target = &self.output_framebuffers[index]; @@ -900,7 +900,7 @@ impl FilterChainD3D12 { cmd, index, &self.common, - pass.config.get_frame_count(frame_count), + pass.meta.get_frame_count(frame_count), options, viewport, &original, @@ -931,7 +931,7 @@ impl FilterChainD3D12 { cmd, passes_len - 1, &self.common, - pass.config.get_frame_count(frame_count), + pass.meta.get_frame_count(frame_count), options, viewport, &original, diff --git a/librashader-runtime-d3d12/src/filter_pass.rs b/librashader-runtime-d3d12/src/filter_pass.rs index d76b926..2e763af 100644 --- a/librashader-runtime-d3d12/src/filter_pass.rs +++ b/librashader-runtime-d3d12/src/filter_pass.rs @@ -10,7 +10,7 @@ use d3d12_descriptor_heap::D3D12DescriptorHeapSlot; use librashader_common::map::FastHashMap; use librashader_common::{ImageFormat, Size, Viewport}; use librashader_preprocess::ShaderSource; -use librashader_presets::ShaderPassConfig; +use librashader_presets::ShaderPassMeta; use librashader_reflect::reflect::semantics::{MemberOffset, TextureBinding, UniformBinding}; use librashader_reflect::reflect::ShaderReflection; use librashader_runtime::binding::{BindSemantics, TextureInput, UniformInputs}; @@ -30,7 +30,7 @@ use windows::Win32::Graphics::Direct3D12::{ pub(crate) struct FilterPass { pub(crate) pipeline: D3D12GraphicsPipeline, pub(crate) reflection: ShaderReflection, - pub(crate) config: ShaderPassConfig, + pub(crate) meta: ShaderPassMeta, pub(crate) uniform_bindings: FastHashMap, pub uniform_storage: UniformStorage, RawD3D12Buffer, RawD3D12Buffer>, @@ -77,8 +77,8 @@ impl FilterPassMeta for FilterPass { self.source.format } - fn config(&self) -> &ShaderPassConfig { - &self.config + fn meta(&self) -> &ShaderPassMeta { + &self.meta } } diff --git a/librashader-runtime-d3d9/src/filter_chain.rs b/librashader-runtime-d3d9/src/filter_chain.rs index 8abd9ee..5f7a5fe 100644 --- a/librashader-runtime-d3d9/src/filter_chain.rs +++ b/librashader-runtime-d3d9/src/filter_chain.rs @@ -170,7 +170,7 @@ impl FilterChainD3D9 { uniform_storage, gl_halfpixel, source, - config, + meta: config, }) }; @@ -309,8 +309,8 @@ impl FilterChainD3D9 { } let options = options.unwrap_or(&self.default_options); - let filter = passes[0].config.filter; - let wrap_mode = passes[0].config.wrap_mode; + let filter = passes[0].meta.filter; + let wrap_mode = passes[0].meta.wrap_mode; for (texture, fbo) in self .common @@ -351,11 +351,7 @@ impl FilterChainD3D9 { .zip(self.feedback_framebuffers.iter()) .zip(passes.iter()) { - *texture = Some(fbo.as_input( - pass.config.filter, - pass.config.filter, - pass.config.wrap_mode, - )); + *texture = Some(fbo.as_input(pass.meta.filter, pass.meta.filter, pass.meta.wrap_mode)); } let passes_len = passes.len(); @@ -363,16 +359,16 @@ impl FilterChainD3D9 { let state_guard = D3D9State::new(&self.common.d3d9)?; for (index, pass) in pass.iter_mut().enumerate() { - source.filter = pass.config.filter; - source.wrap = pass.config.wrap_mode; - source.is_srgb = pass.config.srgb_framebuffer; + source.filter = pass.meta.filter; + source.wrap = pass.meta.wrap_mode; + source.is_srgb = pass.meta.srgb_framebuffer; let target = &self.output_framebuffers[index]; let target_rtv = target.as_output()?; pass.draw( &self.common.d3d9, index, &self.common, - pass.config.get_frame_count(frame_count), + pass.meta.get_frame_count(frame_count), options, viewport, &original, @@ -383,10 +379,10 @@ impl FilterChainD3D9 { source = D3D9InputTexture { handle: target.handle.clone(), - filter: pass.config.filter, - wrap: pass.config.wrap_mode, - mipmode: pass.config.filter, - is_srgb: pass.config.srgb_framebuffer, + filter: pass.meta.filter, + wrap: pass.meta.wrap_mode, + mipmode: pass.meta.filter, + is_srgb: pass.meta.srgb_framebuffer, }; self.common.output_textures[index] = Some(source.clone()); } @@ -395,9 +391,9 @@ impl FilterChainD3D9 { assert_eq!(last.len(), 1); if let Some(pass) = last.iter_mut().next() { let index = passes_len - 1; - source.filter = pass.config.filter; - source.wrap = pass.config.wrap_mode; - source.is_srgb = pass.config.srgb_framebuffer; + source.filter = pass.meta.filter; + source.wrap = pass.meta.wrap_mode; + source.is_srgb = pass.meta.srgb_framebuffer; if self.draw_last_pass_feedback { let feedback_target = &self.output_framebuffers[index]; @@ -407,7 +403,7 @@ impl FilterChainD3D9 { &self.common.d3d9, index, &self.common, - pass.config.get_frame_count(frame_count), + pass.meta.get_frame_count(frame_count), options, viewport, &original, @@ -421,7 +417,7 @@ impl FilterChainD3D9 { &self.common.d3d9, index, &self.common, - pass.config.get_frame_count(frame_count), + pass.meta.get_frame_count(frame_count), options, viewport, &original, diff --git a/librashader-runtime-d3d9/src/filter_pass.rs b/librashader-runtime-d3d9/src/filter_pass.rs index ee0e15a..8b53727 100644 --- a/librashader-runtime-d3d9/src/filter_pass.rs +++ b/librashader-runtime-d3d9/src/filter_pass.rs @@ -8,7 +8,7 @@ use librashader_common::map::FastHashMap; use librashader_common::GetSize; use librashader_common::{ImageFormat, Size, Viewport}; use librashader_preprocess::ShaderSource; -use librashader_presets::ShaderPassConfig; +use librashader_presets::ShaderPassMeta; use librashader_reflect::reflect::semantics::{TextureBinding, UniformBinding}; use librashader_reflect::reflect::ShaderReflection; use librashader_runtime::binding::{BindSemantics, UniformInputs}; @@ -28,7 +28,7 @@ pub struct FilterPass { pub pixel_shader: IDirect3DPixelShader9, pub uniform_bindings: FastHashMap, pub source: ShaderSource, - pub config: ShaderPassConfig, + pub meta: ShaderPassMeta, pub uniform_storage: D3D9UniformStorage, pub gl_halfpixel: Option, } @@ -38,8 +38,8 @@ impl FilterPassMeta for FilterPass { self.source.format } - fn config(&self) -> &ShaderPassConfig { - &self.config + fn meta(&self) -> &ShaderPassMeta { + &self.meta } } @@ -150,7 +150,7 @@ impl FilterPass { output: RenderTarget, vbo_type: QuadType, ) -> error::Result<()> { - if self.config.mipmap_input && !parent.disable_mipmaps { + if self.meta.mipmap_input && !parent.disable_mipmaps { unsafe { source.handle.GenerateMipSubLevels(); } diff --git a/librashader-runtime-gl/src/filter_chain/chain.rs b/librashader-runtime-gl/src/filter_chain/chain.rs index 84aaf1a..33fee52 100644 --- a/librashader-runtime-gl/src/filter_chain/chain.rs +++ b/librashader-runtime-gl/src/filter_chain/chain.rs @@ -147,10 +147,10 @@ impl FilterChainImpl { // initialize passes 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 .first() - .map(|f| f.config.wrap_mode) + .map(|f| f.meta.wrap_mode) .unwrap_or_default(); let samplers = SamplerSet::new(&context)?; @@ -256,7 +256,7 @@ impl FilterChainImpl { uniform_storage, uniform_bindings, source, - config, + meta: config, }); } @@ -309,8 +309,8 @@ impl FilterChainImpl { self.draw_quad .bind_vertices(&self.common.context, QuadType::Offscreen); - let filter = passes[0].config.filter; - let wrap_mode = passes[0].config.wrap_mode; + let filter = passes[0].meta.filter; + let wrap_mode = passes[0].meta.wrap_mode; // update history for (texture, fbo) in self @@ -352,9 +352,7 @@ impl FilterChainImpl { .zip(self.feedback_framebuffers.iter()) .zip(passes.iter()) { - texture.image = fbo - .as_texture(pass.config.filter, pass.config.wrap_mode) - .image; + texture.image = fbo.as_texture(pass.meta.filter, pass.meta.wrap_mode).image; } let passes_len = passes.len(); @@ -364,14 +362,14 @@ impl FilterChainImpl { .bind_vertices(&self.common.context, QuadType::Offscreen); for (index, pass) in pass.iter_mut().enumerate() { let target = &self.output_framebuffers[index]; - source.filter = pass.config.filter; - source.mip_filter = pass.config.filter; - source.wrap_mode = pass.config.wrap_mode; + source.filter = pass.meta.filter; + source.mip_filter = pass.meta.filter; + source.wrap_mode = pass.meta.wrap_mode; pass.draw( index, &self.common, - pass.config.get_frame_count(frame_count), + pass.meta.get_frame_count(frame_count), options, viewport, &original, @@ -379,7 +377,7 @@ impl FilterChainImpl { 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; source = target; } @@ -394,16 +392,16 @@ impl FilterChainImpl { .render_target .ensure::(viewport.output)?; - source.filter = pass.config.filter; - source.mip_filter = pass.config.filter; - source.wrap_mode = pass.config.wrap_mode; + source.filter = pass.meta.filter; + source.mip_filter = pass.meta.filter; + source.wrap_mode = pass.meta.wrap_mode; if self.draw_last_pass_feedback { let target = &self.output_framebuffers[index]; pass.draw( index, &self.common, - pass.config.get_frame_count(frame_count), + pass.meta.get_frame_count(frame_count), options, viewport, &original, @@ -415,7 +413,7 @@ impl FilterChainImpl { pass.draw( index, &self.common, - pass.config.get_frame_count(frame_count), + pass.meta.get_frame_count(frame_count), options, viewport, &original, @@ -424,7 +422,7 @@ impl FilterChainImpl { )?; self.common.output_textures[passes_len - 1] = viewport .output - .as_texture(pass.config.filter, pass.config.wrap_mode); + .as_texture(pass.meta.filter, pass.meta.wrap_mode); } // swap feedback framebuffers with output diff --git a/librashader-runtime-gl/src/filter_pass.rs b/librashader-runtime-gl/src/filter_pass.rs index 77dbef1..3f8e3ae 100644 --- a/librashader-runtime-gl/src/filter_pass.rs +++ b/librashader-runtime-gl/src/filter_pass.rs @@ -4,7 +4,7 @@ use librashader_reflect::reflect::ShaderReflection; use librashader_common::map::FastHashMap; use librashader_common::{ImageFormat, Size, Viewport}; use librashader_preprocess::ShaderSource; -use librashader_presets::ShaderPassConfig; +use librashader_presets::ShaderPassMeta; use librashader_reflect::reflect::semantics::{MemberOffset, TextureBinding, UniformBinding}; use librashader_runtime::binding::{BindSemantics, ContextOffset, TextureInput, UniformInputs}; use librashader_runtime::filter_pass::FilterPassMeta; @@ -38,7 +38,7 @@ pub(crate) struct FilterPass { pub(crate) uniform_storage: GlUniformStorage, pub uniform_bindings: FastHashMap, pub source: ShaderSource, - pub config: ShaderPassConfig, + pub meta: ShaderPassMeta, } impl TextureInput for InputTexture { @@ -89,7 +89,7 @@ impl FilterPass { ) -> error::Result<()> { 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); } @@ -162,8 +162,8 @@ impl FilterPassMeta for FilterPass { self.source.format } - fn config(&self) -> &ShaderPassConfig { - &self.config + fn meta(&self) -> &ShaderPassMeta { + &self.meta } } diff --git a/librashader-runtime-mtl/src/filter_chain.rs b/librashader-runtime-mtl/src/filter_chain.rs index 1dcfc26..df9f874 100644 --- a/librashader-runtime-mtl/src/filter_chain.rs +++ b/librashader-runtime-mtl/src/filter_chain.rs @@ -205,7 +205,7 @@ impl FilterChainMetal { uniform_storage, uniform_bindings, source, - config, + meta: config, graphics_pipeline, }) }) @@ -379,8 +379,8 @@ impl FilterChainMetal { return Ok(()); } - let filter = passes[0].config.filter; - let wrap_mode = passes[0].config.wrap_mode; + let filter = passes[0].meta.filter; + let wrap_mode = passes[0].meta.wrap_mode; // update history for (texture, image) in self @@ -428,9 +428,9 @@ impl FilterChainMetal { feedback: &OwnedTexture| { // refresh inputs 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] = - Some(output.as_input(pass.config.filter, pass.config.wrap_mode)?); + Some(output.as_input(pass.meta.filter, pass.meta.wrap_mode)?); Ok(()) }), )?; @@ -441,16 +441,16 @@ impl FilterChainMetal { for (index, pass) in pass.iter_mut().enumerate() { let target = &self.output_framebuffers[index]; - source.filter_mode = pass.config.filter; - source.wrap_mode = pass.config.wrap_mode; - source.mip_filter = pass.config.filter; + source.filter_mode = pass.meta.filter; + source.wrap_mode = pass.meta.wrap_mode; + source.mip_filter = pass.meta.filter; let out = RenderTarget::identity(target.texture.as_ref())?; pass.draw( &cmd, index, &self.common, - pass.config.get_frame_count(frame_count), + pass.meta.get_frame_count(frame_count), options, viewport, &original, @@ -464,7 +464,7 @@ impl FilterChainMetal { } 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] .as_ref() .map(InputTexture::try_clone) @@ -484,9 +484,9 @@ impl FilterChainMetal { .recompile(&self.common.device, viewport.output.pixelFormat())?; } - source.filter_mode = pass.config.filter; - source.wrap_mode = pass.config.wrap_mode; - source.mip_filter = pass.config.filter; + source.filter_mode = pass.meta.filter; + source.wrap_mode = pass.meta.wrap_mode; + source.mip_filter = pass.meta.filter; let index = passes_len - 1; if self.draw_last_pass_feedback { @@ -496,7 +496,7 @@ impl FilterChainMetal { &cmd, passes_len - 1, &self.common, - pass.config.get_frame_count(frame_count), + pass.meta.get_frame_count(frame_count), options, viewport, &original, @@ -511,7 +511,7 @@ impl FilterChainMetal { &cmd, index, &self.common, - pass.config.get_frame_count(frame_count), + pass.meta.get_frame_count(frame_count), options, viewport, &original, diff --git a/librashader-runtime-mtl/src/filter_pass.rs b/librashader-runtime-mtl/src/filter_pass.rs index f6d852b..1eab383 100644 --- a/librashader-runtime-mtl/src/filter_pass.rs +++ b/librashader-runtime-mtl/src/filter_pass.rs @@ -8,7 +8,7 @@ use crate::texture::{get_texture_size, InputTexture}; use librashader_common::map::FastHashMap; use librashader_common::{ImageFormat, Size, Viewport}; use librashader_preprocess::ShaderSource; -use librashader_presets::ShaderPassConfig; +use librashader_presets::ShaderPassMeta; use librashader_reflect::reflect::semantics::{MemberOffset, TextureBinding, UniformBinding}; use librashader_reflect::reflect::ShaderReflection; use librashader_runtime::binding::{BindSemantics, TextureInput, UniformInputs}; @@ -55,7 +55,7 @@ pub struct FilterPass { UniformStorage, MetalBuffer, MetalBuffer>, pub uniform_bindings: FastHashMap, pub source: ShaderSource, - pub config: ShaderPassConfig, + pub meta: ShaderPassMeta, pub graphics_pipeline: MetalGraphicsPipeline, } @@ -177,7 +177,7 @@ impl FilterPassMeta for FilterPass { self.source.format } - fn config(&self) -> &ShaderPassConfig { - &self.config + fn meta(&self) -> &ShaderPassMeta { + &self.meta } } diff --git a/librashader-runtime-vk/src/filter_chain.rs b/librashader-runtime-vk/src/filter_chain.rs index ab502a0..0ae8b52 100644 --- a/librashader-runtime-vk/src/filter_chain.rs +++ b/librashader-runtime-vk/src/filter_chain.rs @@ -511,7 +511,7 @@ impl FilterChainVulkan { uniform_storage, uniform_bindings, source, - config, + meta: config, graphics_pipeline, // ubo_ring, frames_in_flight, @@ -654,8 +654,8 @@ impl FilterChainVulkan { self.vulkan.device.create_image_view(&create_info, None)? }; - let filter = passes[0].config.filter; - let wrap_mode = passes[0].config.wrap_mode; + let filter = passes[0].meta.filter; + let wrap_mode = passes[0].meta.wrap_mode; // update history for (texture, image) in self @@ -704,9 +704,9 @@ impl FilterChainVulkan { feedback: &OwnedImage| { // refresh inputs 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] = - Some(output.as_input(pass.config.filter, pass.config.wrap_mode)); + Some(output.as_input(pass.meta.filter, pass.meta.wrap_mode)); Ok(()) }), )?; @@ -721,9 +721,9 @@ impl FilterChainVulkan { .bind_vbo_for_frame(&self.vulkan.device, cmd); for (index, pass) in pass.iter_mut().enumerate() { let target = &self.output_framebuffers[index]; - source.filter_mode = pass.config.filter; - source.wrap_mode = pass.config.wrap_mode; - source.mip_filter = pass.config.filter; + source.filter_mode = pass.meta.filter; + source.wrap_mode = pass.meta.wrap_mode; + source.mip_filter = pass.meta.filter; let output_image = OutputImage::new(&self.vulkan.device, target.image.clone())?; let out = RenderTarget::identity(&output_image)?; @@ -733,7 +733,7 @@ impl FilterChainVulkan { target.image.format, index, &self.common, - pass.config.get_frame_count(frame_count), + pass.meta.get_frame_count(frame_count), options, viewport, &original, @@ -768,9 +768,9 @@ impl FilterChainVulkan { pass.graphics_pipeline.recompile(viewport.output.format)?; } - source.filter_mode = pass.config.filter; - source.wrap_mode = pass.config.wrap_mode; - source.mip_filter = pass.config.filter; + source.filter_mode = pass.meta.filter; + source.wrap_mode = pass.meta.wrap_mode; + source.mip_filter = pass.meta.filter; if self.draw_last_pass_feedback { let target = &self.output_framebuffers[index]; @@ -783,7 +783,7 @@ impl FilterChainVulkan { target.image.format, index, &self.common, - pass.config.get_frame_count(frame_count), + pass.meta.get_frame_count(frame_count), options, viewport, &original, @@ -805,7 +805,7 @@ impl FilterChainVulkan { viewport.output.format, index, &self.common, - pass.config.get_frame_count(frame_count), + pass.meta.get_frame_count(frame_count), options, viewport, &original, diff --git a/librashader-runtime-vk/src/filter_pass.rs b/librashader-runtime-vk/src/filter_pass.rs index 8883b2a..f5513a0 100644 --- a/librashader-runtime-vk/src/filter_pass.rs +++ b/librashader-runtime-vk/src/filter_pass.rs @@ -10,7 +10,7 @@ use ash::vk; use librashader_common::map::FastHashMap; use librashader_common::{ImageFormat, Size, Viewport}; use librashader_preprocess::ShaderSource; -use librashader_presets::ShaderPassConfig; +use librashader_presets::ShaderPassMeta; use librashader_reflect::reflect::semantics::{ BindingStage, MemberOffset, TextureBinding, UniformBinding, }; @@ -28,7 +28,7 @@ pub struct FilterPass { UniformStorage, RawVulkanBuffer, Box<[u8]>, Arc>, pub uniform_bindings: FastHashMap, pub source: ShaderSource, - pub config: ShaderPassConfig, + pub meta: ShaderPassMeta, pub graphics_pipeline: VulkanGraphicsPipeline, pub frames_in_flight: u32, } @@ -78,8 +78,8 @@ impl FilterPassMeta for FilterPass { self.source.format } - fn config(&self) -> &ShaderPassConfig { - &self.config + fn meta(&self) -> &ShaderPassMeta { + &self.meta } } diff --git a/librashader-runtime-wgpu/src/filter_chain.rs b/librashader-runtime-wgpu/src/filter_chain.rs index 61ebbf6..396cb52 100644 --- a/librashader-runtime-wgpu/src/filter_chain.rs +++ b/librashader-runtime-wgpu/src/filter_chain.rs @@ -336,7 +336,7 @@ impl FilterChainWgpu { uniform_storage, uniform_bindings, source, - config, + meta: config, graphics_pipeline, }) }) @@ -389,8 +389,8 @@ impl FilterChainWgpu { let original_image_view = input.create_view(&wgpu::TextureViewDescriptor::default()); - let filter = passes[0].config.filter; - let wrap_mode = passes[0].config.wrap_mode; + let filter = passes[0].meta.filter; + let wrap_mode = passes[0].meta.wrap_mode; // update history for (texture, image) in self @@ -433,9 +433,9 @@ impl FilterChainWgpu { feedback: &OwnedImage| { // refresh inputs 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] = - Some(output.as_input(pass.config.filter, pass.config.wrap_mode)); + Some(output.as_input(pass.meta.filter, pass.meta.wrap_mode)); Ok(()) }), )?; @@ -446,9 +446,9 @@ impl FilterChainWgpu { let options = options.unwrap_or(&self.default_frame_options); for (index, pass) in pass.iter_mut().enumerate() { - source.filter_mode = pass.config.filter; - source.wrap_mode = pass.config.wrap_mode; - source.mip_filter = pass.config.filter; + source.filter_mode = pass.meta.filter; + source.wrap_mode = pass.meta.wrap_mode; + source.mip_filter = pass.meta.filter; let target = &self.output_framebuffers[index]; let output_image = WgpuOutputView::from(target); @@ -458,7 +458,7 @@ impl FilterChainWgpu { cmd, index, &self.common, - pass.config.get_frame_count(frame_count), + pass.meta.get_frame_count(frame_count), options, viewport, &original, @@ -490,9 +490,9 @@ impl FilterChainWgpu { pass.graphics_pipeline.recompile(viewport.output.format); } - source.filter_mode = pass.config.filter; - source.wrap_mode = pass.config.wrap_mode; - source.mip_filter = pass.config.filter; + source.filter_mode = pass.meta.filter; + source.wrap_mode = pass.meta.wrap_mode; + source.mip_filter = pass.meta.filter; if self.draw_last_pass_feedback { let target = &self.output_framebuffers[index]; @@ -503,7 +503,7 @@ impl FilterChainWgpu { cmd, index, &self.common, - pass.config.get_frame_count(frame_count), + pass.meta.get_frame_count(frame_count), options, viewport, &original, @@ -518,7 +518,7 @@ impl FilterChainWgpu { cmd, index, &self.common, - pass.config.get_frame_count(frame_count), + pass.meta.get_frame_count(frame_count), options, viewport, &original, diff --git a/librashader-runtime-wgpu/src/filter_pass.rs b/librashader-runtime-wgpu/src/filter_pass.rs index f50935a..399eba5 100644 --- a/librashader-runtime-wgpu/src/filter_pass.rs +++ b/librashader-runtime-wgpu/src/filter_pass.rs @@ -9,7 +9,7 @@ use crate::texture::InputImage; use librashader_common::map::FastHashMap; use librashader_common::{ImageFormat, Size, Viewport}; use librashader_preprocess::ShaderSource; -use librashader_presets::ShaderPassConfig; +use librashader_presets::ShaderPassMeta; use librashader_reflect::reflect::semantics::{ BindingStage, MemberOffset, TextureBinding, UniformBinding, }; @@ -34,7 +34,7 @@ pub struct FilterPass { >, pub uniform_bindings: FastHashMap, pub source: ShaderSource, - pub config: ShaderPassConfig, + pub meta: ShaderPassMeta, pub graphics_pipeline: WgpuGraphicsPipeline, } @@ -255,7 +255,7 @@ impl FilterPassMeta for FilterPass { self.source.format } - fn config(&self) -> &ShaderPassConfig { - &self.config + fn meta(&self) -> &ShaderPassMeta { + &self.meta } } diff --git a/librashader-runtime/src/filter_pass.rs b/librashader-runtime/src/filter_pass.rs index d7c813c..e772b49 100644 --- a/librashader-runtime/src/filter_pass.rs +++ b/librashader-runtime/src/filter_pass.rs @@ -1,5 +1,5 @@ use librashader_common::ImageFormat; -use librashader_presets::ShaderPassConfig; +use librashader_presets::ShaderPassMeta; /// Trait for metadata about a filter pass. pub trait FilterPassMeta { @@ -7,13 +7,13 @@ pub trait FilterPassMeta { fn framebuffer_format(&self) -> ImageFormat; /// Gets a reference to the filter pass config. - fn config(&self) -> &ShaderPassConfig; + fn meta(&self) -> &ShaderPassMeta; /// Gets the format of the filter pass framebuffer. #[inline(always)] fn get_format(&self) -> ImageFormat { 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 } else if fb_format == ImageFormat::Unknown { ImageFormat::R8G8B8A8Unorm diff --git a/librashader-runtime/src/scaling.rs b/librashader-runtime/src/scaling.rs index 2b76c09..2b075ff 100644 --- a/librashader-runtime/src/scaling.rs +++ b/librashader-runtime/src/scaling.rs @@ -212,10 +212,10 @@ where while let Some((index, pass)) = iterator.next() { let should_mipmap = iterator .peek() - .map_or(false, |(_, p)| p.config().mipmap_input); + .map_or(false, |(_, p)| p.meta().mipmap_input); let next_size = output[index].scale( - pass.config().scaling.clone(), + pass.meta().scaling.clone(), pass.get_format(), &viewport_size, &target_size, @@ -225,7 +225,7 @@ where )?; feedback[index].scale( - pass.config().scaling.clone(), + pass.meta().scaling.clone(), pass.get_format(), &viewport_size, &target_size,