From 3ee5e66c0d8bcd58e612f60dca8de1db4e7bbe5f Mon Sep 17 00:00:00 2001 From: chyyran Date: Wed, 2 Oct 2024 17:49:30 -0400 Subject: [PATCH] presets: make naming more consistent * `ShaderPassConfig` -> `PassConfig` * `ShaderPassData` -> `PassResource` * `TextureData` -> `TextureResource` * `ShaderPresetResource` -> `LoadedResource` * `ShaderPassMeta` -> `PassMeta` * `ShaderPreset::shaders` -> `ShaderPreset::passes` * `ShaderPreset::shader_count` -> `ShaderPreset::pass_count` * `ShaderPresetPack::shaders` -> `ShaderPresetPack::passes` * `ShaderPresetPack::shader_count` -> `ShaderPresetPack::pass_count` --- librashader-capi/src/reflect/mod.rs | 6 ++-- librashader-cli/src/cli/main.rs | 2 +- librashader-pack/src/lib.rs | 32 ++++++++++--------- librashader-presets/src/parse/preset.rs | 11 +++---- librashader-presets/src/preset.rs | 10 +++--- librashader-reflect/src/lib.rs | 2 +- librashader-reflect/src/reflect/presets.rs | 14 ++++---- librashader-runtime-d3d11/src/filter_chain.rs | 14 ++++---- librashader-runtime-d3d11/src/filter_pass.rs | 6 ++-- librashader-runtime-d3d12/src/filter_chain.rs | 22 ++++++------- librashader-runtime-d3d12/src/filter_pass.rs | 6 ++-- librashader-runtime-d3d9/src/filter_chain.rs | 14 ++++---- librashader-runtime-d3d9/src/filter_pass.rs | 6 ++-- .../src/filter_chain/chain.rs | 10 +++--- librashader-runtime-gl/src/filter_pass.rs | 6 ++-- librashader-runtime-gl/src/gl/gl3/lut_load.rs | 4 +-- .../src/gl/gl46/lut_load.rs | 4 +-- librashader-runtime-gl/src/gl/mod.rs | 4 +-- librashader-runtime-mtl/src/filter_chain.rs | 14 ++++---- librashader-runtime-mtl/src/filter_pass.rs | 6 ++-- librashader-runtime-vk/src/filter_chain.rs | 14 ++++---- librashader-runtime-vk/src/filter_pass.rs | 6 ++-- librashader-runtime-wgpu/src/filter_chain.rs | 14 ++++---- librashader-runtime-wgpu/src/filter_pass.rs | 6 ++-- librashader-runtime/src/filter_pass.rs | 4 +-- librashader-runtime/src/image.rs | 9 ++++-- librashader/src/lib.rs | 4 +-- librashader/tests/reflect.rs | 14 ++++---- 28 files changed, 134 insertions(+), 130 deletions(-) diff --git a/librashader-capi/src/reflect/mod.rs b/librashader-capi/src/reflect/mod.rs index 5901972..d6dbc88 100644 --- a/librashader-capi/src/reflect/mod.rs +++ b/librashader-capi/src/reflect/mod.rs @@ -1,6 +1,6 @@ use crate::error; -use librashader::presets::{ShaderPassConfig, ShaderPreset}; +use librashader::presets::{PassConfig, ShaderPreset}; use librashader::reflect::semantics::ShaderSemantics; use librashader::reflect::targets::SPIRV; use librashader::reflect::{CompileShader, ReflectShader, ShaderCompilerOutput, ShaderReflection}; @@ -21,7 +21,7 @@ pub(crate) struct LookupTexture { pub(crate) struct PassReflection { reflection: ShaderReflection, - config: ShaderPassConfig, + config: PassConfig, spirv: ShaderCompilerOutput>, } pub(crate) struct FilterReflection { @@ -35,7 +35,7 @@ impl FilterReflection { preset: ShaderPreset, direction: UVDirection, ) -> Result { - let (passes, textures) = (preset.shaders, preset.textures); + let (passes, textures) = (preset.passes, preset.textures); let (passes, semantics) = librashader::reflect::helper::compile_preset_passes::< Glslang, diff --git a/librashader-cli/src/cli/main.rs b/librashader-cli/src/cli/main.rs index 9ed2e6d..0b4f9d4 100644 --- a/librashader-cli/src/cli/main.rs +++ b/librashader-cli/src/cli/main.rs @@ -509,7 +509,7 @@ pub fn main() -> Result<(), anyhow::Error> { let PresetArgs { preset, wildcards } = preset; let preset = get_shader_preset(preset, wildcards)?; - let Some(shader) = preset.shaders.get(index) else { + let Some(shader) = preset.passes.get(index) else { return Err(anyhow!("Invalid pass index for the preset")); }; diff --git a/librashader-pack/src/lib.rs b/librashader-pack/src/lib.rs index 44cf7d8..38b90dc 100644 --- a/librashader-pack/src/lib.rs +++ b/librashader-pack/src/lib.rs @@ -6,7 +6,7 @@ //! use image::{ImageError, RgbaImage}; use librashader_preprocess::{PreprocessError, ShaderSource}; -use librashader_presets::{ParameterMeta, ShaderPassMeta, ShaderPreset, TextureMeta}; +use librashader_presets::{ParameterMeta, PassMeta, ShaderPreset, TextureMeta}; use std::path::Path; #[cfg(not(target_arch = "wasm32"))] @@ -49,7 +49,7 @@ impl From for TextureBuffer { /// A resource for a shader preset, fully loaded into memory. #[derive(Debug, Clone)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ShaderPresetResource { +pub struct LoadedResource { /// The fully qualified path to the texture. pub data: M::ResourceType, /// Meta information about the texture. @@ -66,7 +66,7 @@ pub trait LoadableResource { fn load(path: &Path) -> Result; } -impl LoadableResource for ShaderPassMeta { +impl LoadableResource for PassMeta { type ResourceType = ShaderSource; type Error = PreprocessError; @@ -84,9 +84,11 @@ impl LoadableResource for TextureMeta { } } -/// The configuration for a single shader pass. -pub type ShaderPassData = ShaderPresetResource; -pub type TextureData = ShaderPresetResource; +/// The loaded resource information for the source code of a shader pass. +pub type PassResource = LoadedResource; + +/// The loaded texture resource for a shader preset. +pub type TextureResource = LoadedResource; /// A fully loaded-in-memory shader preset, with all paths resolved to data. #[derive(Debug, Clone)] @@ -98,13 +100,13 @@ pub struct ShaderPresetPack { pub feedback_pass: i32, /// The number of shaders enabled in the filter chain. - pub shader_count: i32, + pub pass_count: i32, // Everything is in Vecs because the expect number of values is well below 64. /// Preset information for each shader. - pub shaders: Vec, + pub passes: Vec, /// Preset information for each texture. - pub textures: Vec, + pub textures: Vec, /// Preset information for each user parameter. pub parameters: Vec, @@ -119,7 +121,7 @@ impl ShaderPresetPack { E: Send, { #[cfg(not(target_arch = "wasm32"))] - let shaders_iter = preset.shaders.into_par_iter(); + let shaders_iter = preset.passes.into_par_iter(); #[cfg(target_arch = "wasm32")] let shaders_iter = preset.shaders.into_iter(); @@ -134,11 +136,11 @@ impl ShaderPresetPack { #[cfg(feature = "parse_legacy_glsl")] feedback_pass: preset.feedback_pass, - shader_count: preset.shader_count, - shaders: shaders_iter + pass_count: preset.pass_count, + passes: shaders_iter .map(|v| { - Ok::<_, E>(ShaderPassData { - data: ShaderPassMeta::load(v.path.as_path())?, + Ok::<_, E>(PassResource { + data: PassMeta::load(v.path.as_path())?, meta: v.meta, }) }) @@ -146,7 +148,7 @@ impl ShaderPresetPack { textures: textures_iter .into_par_iter() .map(|t| { - Ok::<_, E>(TextureData { + Ok::<_, E>(TextureResource { data: TextureMeta::load(t.path.as_path())?, meta: t.meta, }) diff --git a/librashader-presets/src/parse/preset.rs b/librashader-presets/src/parse/preset.rs index 9dd227b..fb43c6f 100644 --- a/librashader-presets/src/parse/preset.rs +++ b/librashader-presets/src/parse/preset.rs @@ -1,8 +1,7 @@ use crate::parse::remove_if; use crate::parse::value::Value; use crate::{ - ParameterMeta, Scale2D, Scaling, ShaderPassConfig, ShaderPassMeta, ShaderPreset, TextureConfig, - TextureMeta, + ParameterMeta, PassConfig, PassMeta, Scale2D, Scaling, ShaderPreset, TextureConfig, TextureMeta, }; use vec_extract_if_polyfill::MakeExtractIf; @@ -118,9 +117,9 @@ pub fn resolve_values(mut values: Vec) -> ShaderPreset { scale_y = scale; } - let shader = ShaderPassConfig { + let shader = PassConfig { path: name, - meta: ShaderPassMeta { + meta: PassMeta { id, alias: shader_values.iter().find_map(|f| match f { Value::Alias(_, value) => Some(value.clone()), @@ -189,8 +188,8 @@ pub fn resolve_values(mut values: Vec) -> ShaderPreset { ShaderPreset { #[cfg(feature = "parse_legacy_glsl")] feedback_pass, - shader_count, - shaders, + pass_count: shader_count, + passes: shaders, textures, parameters, } diff --git a/librashader-presets/src/preset.rs b/librashader-presets/src/preset.rs index 78b52f4..0524114 100644 --- a/librashader-presets/src/preset.rs +++ b/librashader-presets/src/preset.rs @@ -6,7 +6,7 @@ use std::path::PathBuf; use std::str::FromStr; /// The configuration for a single shader pass. -pub type ShaderPassConfig = PathReference; +pub type PassConfig = PathReference; /// Configuration options for a lookup texture used in the shader. pub type TextureConfig = PathReference; @@ -24,7 +24,7 @@ pub struct PathReference { /// Meta information about a shader pass. #[derive(Debug, Clone)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ShaderPassMeta { +pub struct PassMeta { /// The index of the shader pass relative to its parent preset. pub id: i32, /// The alias of the shader pass if available. @@ -45,7 +45,7 @@ pub struct ShaderPassMeta { pub scaling: Scale2D, } -impl ShaderPassMeta { +impl PassMeta { /// If the framebuffer expects a different format than what was defined in the /// shader source, returns such format. #[inline(always)] @@ -204,10 +204,10 @@ pub struct ShaderPreset { pub feedback_pass: i32, /// The number of shaders enabled in the filter chain. - pub shader_count: i32, + pub pass_count: i32, // Everything is in Vecs because the expect number of values is well below 64. /// Preset information for each shader. - pub shaders: Vec, + pub passes: Vec, /// Preset information for each texture. pub textures: Vec, diff --git a/librashader-reflect/src/lib.rs b/librashader-reflect/src/lib.rs index 68e1425..f4582df 100644 --- a/librashader-reflect/src/lib.rs +++ b/librashader-reflect/src/lib.rs @@ -34,7 +34,7 @@ //! pub fn compile_preset(preset: ShaderPreset) -> Result<(Vec, ShaderSemantics), Box> //! { //! let (passes, semantics) = SPIRV::compile_preset_passes::>( -//! preset.shaders, &preset.textures)?; +//! preset.passes, &preset.textures)?; //! Ok((passes, semantics)) //! } //! ``` diff --git a/librashader-reflect/src/reflect/presets.rs b/librashader-reflect/src/reflect/presets.rs index 47605e1..dc0e581 100644 --- a/librashader-reflect/src/reflect/presets.rs +++ b/librashader-reflect/src/reflect/presets.rs @@ -6,9 +6,9 @@ use crate::reflect::semantics::{ Semantic, ShaderSemantics, TextureSemantics, UniformSemantic, UniqueSemantics, }; use librashader_common::map::{FastHashMap, ShortString}; -use librashader_pack::ShaderPassData; +use librashader_pack::PassResource; use librashader_preprocess::{PreprocessError, ShaderSource}; -use librashader_presets::{ShaderPassMeta, ShaderPreset, TextureMeta}; +use librashader_presets::{PassMeta, ShaderPreset, TextureMeta}; /// Artifacts of a reflected and compiled shader pass. /// @@ -28,7 +28,7 @@ use librashader_presets::{ShaderPassMeta, ShaderPreset, TextureMeta}; /// ``` /// /// This allows a runtime to not name the backing type of the compiled artifact if not necessary. -pub type ShaderPassArtifact = (ShaderPassMeta, ShaderSource, CompilerBackend); +pub type ShaderPassArtifact = (PassMeta, ShaderSource, CompilerBackend); impl CompilePresetTarget for T {} @@ -38,7 +38,7 @@ pub trait CompilePresetTarget: OutputTarget { /// Compile passes of a shader preset given the applicable /// shader output target, compilation type, and resulting error. fn compile_preset_passes<'a, I, R, E>( - passes: Vec, + passes: Vec, textures: impl Iterator, ) -> Result< ( @@ -63,7 +63,7 @@ pub trait CompilePresetTarget: OutputTarget { /// Compile passes of a shader preset given the applicable /// shader output target, compilation type, and resulting error. fn compile_preset_passes<'a, T, I, R, E>( - passes: Vec, + passes: Vec, textures: impl Iterator, ) -> Result< ( @@ -103,7 +103,7 @@ where } Ok::<_, E>((shader.meta, source, reflect)) }) - .collect::)>, E>>()?; + .collect::)>, E>>()?; for (meta, source, _) in &passes { insert_pass_semantics( @@ -232,7 +232,7 @@ impl ShaderSemantics { Default::default(); let config = preset - .shaders + .passes .get(index) .ok_or_else(|| PreprocessError::InvalidStage)?; diff --git a/librashader-runtime-d3d11/src/filter_chain.rs b/librashader-runtime-d3d11/src/filter_chain.rs index f3092b1..124ef46 100644 --- a/librashader-runtime-d3d11/src/filter_chain.rs +++ b/librashader-runtime-d3d11/src/filter_chain.rs @@ -75,7 +75,7 @@ pub(crate) struct FilterCommon { mod compile { use super::*; - use librashader_pack::{ShaderPassData, TextureData}; + use librashader_pack::{PassResource, TextureResource}; #[cfg(not(feature = "stable"))] pub type ShaderPassMeta = @@ -87,8 +87,8 @@ mod compile { >; pub fn compile_passes( - shaders: Vec, - textures: &[TextureData], + shaders: Vec, + textures: &[TextureResource], disable_cache: bool, ) -> Result<(Vec, ShaderSemantics), FilterChainError> { let (passes, semantics) = if !disable_cache { @@ -109,7 +109,7 @@ mod compile { } use compile::{compile_passes, ShaderPassMeta}; -use librashader_pack::{ShaderPresetPack, TextureData}; +use librashader_pack::{ShaderPresetPack, TextureResource}; use librashader_runtime::parameters::RuntimeParameters; impl FilterChainD3D11 { @@ -193,7 +193,7 @@ impl FilterChainD3D11 { ) -> error::Result { let disable_cache = options.map_or(false, |o| o.disable_cache); - let (passes, semantics) = compile_passes(preset.shaders, &preset.textures, disable_cache)?; + let (passes, semantics) = compile_passes(preset.passes, &preset.textures, disable_cache)?; let samplers = SamplerSet::new(device)?; @@ -237,7 +237,7 @@ impl FilterChainD3D11 { _device: device.clone(), immediate_context, }, - config: RuntimeParameters::new(preset.shader_count as usize, preset.parameters), + config: RuntimeParameters::new(preset.pass_count as usize, preset.parameters), disable_mipmaps: options.map_or(false, |o| o.force_no_mipmaps), luts, samplers, @@ -399,7 +399,7 @@ impl FilterChainD3D11 { fn load_luts( device: &ID3D11Device, context: &ID3D11DeviceContext, - textures: Vec, + textures: Vec, ) -> error::Result> { let mut luts = FastHashMap::default(); let textures = textures diff --git a/librashader-runtime-d3d11/src/filter_pass.rs b/librashader-runtime-d3d11/src/filter_pass.rs index bbd5f5e..f7e128c 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::ShaderPassMeta; +use librashader_presets::PassMeta; 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 meta: ShaderPassMeta, + pub meta: PassMeta, } // https://doc.rust-lang.org/nightly/core/array/fn.from_fn.html is not ~const :( @@ -90,7 +90,7 @@ impl FilterPassMeta for FilterPass { self.source.format } - fn meta(&self) -> &ShaderPassMeta { + fn meta(&self) -> &PassMeta { &self.meta } } diff --git a/librashader-runtime-d3d12/src/filter_chain.rs b/librashader-runtime-d3d12/src/filter_chain.rs index aaf202b..28017e4 100644 --- a/librashader-runtime-d3d12/src/filter_chain.rs +++ b/librashader-runtime-d3d12/src/filter_chain.rs @@ -175,7 +175,7 @@ impl Drop for FrameResiduals { mod compile { use super::*; - use librashader_pack::ShaderPassData; + use librashader_pack::PassResource; #[cfg(not(feature = "stable"))] pub type DxilShaderPassMeta = @@ -187,8 +187,8 @@ mod compile { >; pub fn compile_passes_dxil( - shaders: Vec, - textures: &[TextureData], + shaders: Vec, + textures: &[TextureResource], disable_cache: bool, ) -> Result<(Vec, ShaderSemantics), FilterChainError> { let (passes, semantics) = if !disable_cache { @@ -217,8 +217,8 @@ mod compile { >; pub fn compile_passes_hlsl( - shaders: Vec, - textures: &[TextureData], + shaders: Vec, + textures: &[TextureResource], disable_cache: bool, ) -> Result<(Vec, ShaderSemantics), FilterChainError> { let (passes, semantics) = if !disable_cache { @@ -240,7 +240,7 @@ mod compile { use crate::resource::OutlivesFrame; use compile::{compile_passes_dxil, compile_passes_hlsl, DxilShaderPassMeta, HlslShaderPassMeta}; -use librashader_pack::{ShaderPresetPack, TextureData}; +use librashader_pack::{ShaderPresetPack, TextureResource}; use librashader_runtime::parameters::RuntimeParameters; impl FilterChainD3D12 { @@ -335,14 +335,14 @@ impl FilterChainD3D12 { cmd: &ID3D12GraphicsCommandList, options: Option<&FilterChainOptionsD3D12>, ) -> error::Result { - let shader_count = preset.shaders.len(); + let shader_count = preset.passes.len(); let lut_count = preset.textures.len(); - let shader_copy = preset.shaders.clone(); + let shader_copy = preset.passes.clone(); let disable_cache = options.map_or(false, |o| o.disable_cache); let (passes, semantics) = - compile_passes_dxil(preset.shaders, &preset.textures, disable_cache)?; + compile_passes_dxil(preset.passes, &preset.textures, disable_cache)?; let (hlsl_passes, _) = compile_passes_hlsl(shader_copy, &preset.textures, disable_cache)?; let samplers = SamplerSet::new(device)?; @@ -436,7 +436,7 @@ impl FilterChainD3D12 { mipmap_gen, root_signature, draw_quad, - config: RuntimeParameters::new(preset.shader_count as usize, preset.parameters), + config: RuntimeParameters::new(preset.pass_count as usize, preset.parameters), history_textures, }, staging_heap, @@ -461,7 +461,7 @@ impl FilterChainD3D12 { staging_heap: &mut D3D12DescriptorHeap, mipmap_heap: &mut D3D12DescriptorHeap, gc: &mut FrameResiduals, - textures: Vec, + textures: Vec, ) -> error::Result> { // use separate mipgen to load luts. let mipmap_gen = D3D12MipmapGen::new(device, true)?; diff --git a/librashader-runtime-d3d12/src/filter_pass.rs b/librashader-runtime-d3d12/src/filter_pass.rs index 2e763af..4837ea3 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::ShaderPassMeta; +use librashader_presets::PassMeta; 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) meta: ShaderPassMeta, + pub(crate) meta: PassMeta, pub(crate) uniform_bindings: FastHashMap, pub uniform_storage: UniformStorage, RawD3D12Buffer, RawD3D12Buffer>, @@ -77,7 +77,7 @@ impl FilterPassMeta for FilterPass { self.source.format } - fn meta(&self) -> &ShaderPassMeta { + fn meta(&self) -> &PassMeta { &self.meta } } diff --git a/librashader-runtime-d3d9/src/filter_chain.rs b/librashader-runtime-d3d9/src/filter_chain.rs index f6e06fb..8c896eb 100644 --- a/librashader-runtime-d3d9/src/filter_chain.rs +++ b/librashader-runtime-d3d9/src/filter_chain.rs @@ -63,7 +63,7 @@ pub struct FilterChainD3D9 { mod compile { use super::*; - use librashader_pack::{ShaderPassData, TextureData}; + use librashader_pack::{PassResource, TextureResource}; #[cfg(not(feature = "stable"))] pub type ShaderPassMeta = @@ -75,8 +75,8 @@ mod compile { >; pub fn compile_passes( - shaders: Vec, - textures: &[TextureData], + shaders: Vec, + textures: &[TextureResource], disable_cache: bool, ) -> Result<(Vec, ShaderSemantics), FilterChainError> { let (passes, semantics) = if !disable_cache { @@ -97,7 +97,7 @@ mod compile { } use compile::{compile_passes, ShaderPassMeta}; -use librashader_pack::{ShaderPresetPack, TextureData}; +use librashader_pack::{ShaderPresetPack, TextureResource}; use librashader_runtime::parameters::RuntimeParameters; impl FilterChainD3D9 { @@ -189,7 +189,7 @@ impl FilterChainD3D9 { fn load_luts( device: &IDirect3DDevice9, - textures: Vec, + textures: Vec, ) -> error::Result> { let mut luts = FastHashMap::default(); let images = textures @@ -236,7 +236,7 @@ impl FilterChainD3D9 { ) -> error::Result { let disable_cache = options.map_or(false, |o| o.disable_cache); - let (passes, semantics) = compile_passes(preset.shaders, &preset.textures, disable_cache)?; + let (passes, semantics) = compile_passes(preset.passes, &preset.textures, disable_cache)?; let samplers = SamplerSet::new()?; @@ -275,7 +275,7 @@ impl FilterChainD3D9 { history_framebuffers, common: FilterCommon { d3d9: device.clone(), - config: RuntimeParameters::new(preset.shader_count as usize, preset.parameters), + config: RuntimeParameters::new(preset.pass_count as usize, preset.parameters), disable_mipmaps: options.map_or(false, |o| o.force_no_mipmaps), luts, samplers, diff --git a/librashader-runtime-d3d9/src/filter_pass.rs b/librashader-runtime-d3d9/src/filter_pass.rs index 8b53727..0fc43a6 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::ShaderPassMeta; +use librashader_presets::PassMeta; 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 meta: ShaderPassMeta, + pub meta: PassMeta, pub uniform_storage: D3D9UniformStorage, pub gl_halfpixel: Option, } @@ -38,7 +38,7 @@ impl FilterPassMeta for FilterPass { self.source.format } - fn meta(&self) -> &ShaderPassMeta { + fn meta(&self) -> &PassMeta { &self.meta } } diff --git a/librashader-runtime-gl/src/filter_chain/chain.rs b/librashader-runtime-gl/src/filter_chain/chain.rs index 567ce68..f19c9d2 100644 --- a/librashader-runtime-gl/src/filter_chain/chain.rs +++ b/librashader-runtime-gl/src/filter_chain/chain.rs @@ -21,7 +21,7 @@ use librashader_reflect::reflect::semantics::{ShaderSemantics, UniformMeta}; use glow::HasContext; use librashader_cache::CachedCompilation; use librashader_common::map::FastHashMap; -use librashader_pack::{ShaderPassData, ShaderPresetPack, TextureData}; +use librashader_pack::{PassResource, ShaderPresetPack, TextureResource}; use librashader_reflect::reflect::cross::SpirvCross; use librashader_reflect::reflect::presets::{CompilePresetTarget, ShaderPassArtifact}; use librashader_reflect::reflect::ReflectShader; @@ -108,8 +108,8 @@ mod compile { >; pub fn compile_passes( - shaders: Vec, - textures: &[TextureData], + shaders: Vec, + textures: &[TextureResource], disable_cache: bool, ) -> Result<(Vec, ShaderSemantics), FilterChainError> { let (passes, semantics) = if !disable_cache { @@ -140,7 +140,7 @@ impl FilterChainImpl { options: Option<&FilterChainOptionsGL>, ) -> error::Result { let disable_cache = options.map_or(false, |o| o.disable_cache); - let (passes, semantics) = compile_passes(preset.shaders, &preset.textures, disable_cache)?; + let (passes, semantics) = compile_passes(preset.passes, &preset.textures, disable_cache)?; let version = options.map_or_else( || gl_get_version(&context), |o| gl_u16_to_version(&context, o.glsl_version), @@ -197,7 +197,7 @@ impl FilterChainImpl { history_framebuffers, draw_quad, common: FilterCommon { - config: RuntimeParameters::new(preset.shader_count as usize, preset.parameters), + config: RuntimeParameters::new(preset.pass_count as usize, preset.parameters), disable_mipmaps: options.map_or(false, |o| o.force_no_mipmaps), luts, samplers, diff --git a/librashader-runtime-gl/src/filter_pass.rs b/librashader-runtime-gl/src/filter_pass.rs index 3f8e3ae..86da51a 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::ShaderPassMeta; +use librashader_presets::PassMeta; 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 meta: ShaderPassMeta, + pub meta: PassMeta, } impl TextureInput for InputTexture { @@ -162,7 +162,7 @@ impl FilterPassMeta for FilterPass { self.source.format } - fn meta(&self) -> &ShaderPassMeta { + fn meta(&self) -> &PassMeta { &self.meta } } diff --git a/librashader-runtime-gl/src/gl/gl3/lut_load.rs b/librashader-runtime-gl/src/gl/gl3/lut_load.rs index 3408f0d..c0393b5 100644 --- a/librashader-runtime-gl/src/gl/gl3/lut_load.rs +++ b/librashader-runtime-gl/src/gl/gl3/lut_load.rs @@ -4,7 +4,7 @@ use crate::gl::LoadLut; use crate::texture::InputTexture; use glow::{HasContext, PixelUnpackData}; use librashader_common::map::FastHashMap; -use librashader_pack::TextureData; +use librashader_pack::TextureResource; use librashader_runtime::image::{ImageError, LoadedTexture, UVDirection}; use librashader_runtime::scaling::MipmapSize; use rayon::prelude::*; @@ -14,7 +14,7 @@ pub struct Gl3LutLoad; impl LoadLut for Gl3LutLoad { fn load_luts( context: &glow::Context, - textures: Vec, + textures: Vec, ) -> Result> { let mut luts = FastHashMap::default(); let pixel_unpack = unsafe { context.get_parameter_i32(glow::PIXEL_UNPACK_BUFFER_BINDING) }; diff --git a/librashader-runtime-gl/src/gl/gl46/lut_load.rs b/librashader-runtime-gl/src/gl/gl46/lut_load.rs index f852f98..2c88831 100644 --- a/librashader-runtime-gl/src/gl/gl46/lut_load.rs +++ b/librashader-runtime-gl/src/gl/gl46/lut_load.rs @@ -4,7 +4,7 @@ use crate::gl::LoadLut; use crate::texture::InputTexture; use glow::{HasContext, PixelUnpackData}; use librashader_common::map::FastHashMap; -use librashader_pack::TextureData; +use librashader_pack::TextureResource; use librashader_runtime::image::{ImageError, LoadedTexture, UVDirection}; use librashader_runtime::scaling::MipmapSize; use rayon::prelude::*; @@ -13,7 +13,7 @@ pub struct Gl46LutLoad; impl LoadLut for Gl46LutLoad { fn load_luts( context: &glow::Context, - textures: Vec, + textures: Vec, ) -> Result> { let mut luts = FastHashMap::default(); diff --git a/librashader-runtime-gl/src/gl/mod.rs b/librashader-runtime-gl/src/gl/mod.rs index 0313840..61e12e1 100644 --- a/librashader-runtime-gl/src/gl/mod.rs +++ b/librashader-runtime-gl/src/gl/mod.rs @@ -60,7 +60,7 @@ static FINAL_VBO_DATA: &[VertexInput; 4] = &[ pub(crate) trait LoadLut { fn load_luts( context: &glow::Context, - textures: Vec, + textures: Vec, ) -> Result>; } @@ -172,4 +172,4 @@ pub(crate) trait GLInterface { } pub(crate) use framebuffer::OutputFramebuffer; -use librashader_pack::TextureData; +use librashader_pack::TextureResource; diff --git a/librashader-runtime-mtl/src/filter_chain.rs b/librashader-runtime-mtl/src/filter_chain.rs index 85ed24f..fa2164e 100644 --- a/librashader-runtime-mtl/src/filter_chain.rs +++ b/librashader-runtime-mtl/src/filter_chain.rs @@ -41,7 +41,7 @@ use std::path::Path; mod compile { use super::*; - use librashader_pack::{ShaderPassData, TextureData}; + use librashader_pack::{PassResource, TextureResource}; #[cfg(not(feature = "stable"))] pub type ShaderPassMeta = @@ -52,8 +52,8 @@ mod compile { ShaderPassArtifact + Send>>; pub fn compile_passes( - shaders: Vec, - textures: &[TextureData], + shaders: Vec, + textures: &[TextureResource], ) -> Result<(Vec, ShaderSemantics), FilterChainError> { let (passes, semantics) = MSL::compile_preset_passes::< SpirvCompilation, @@ -65,7 +65,7 @@ mod compile { } use compile::{compile_passes, ShaderPassMeta}; -use librashader_pack::{ShaderPresetPack, TextureData}; +use librashader_pack::{ShaderPresetPack, TextureResource}; use librashader_runtime::parameters::RuntimeParameters; /// A Metal filter chain. @@ -149,7 +149,7 @@ impl FilterChainMetal { fn load_luts( device: &ProtocolObject, cmd: &ProtocolObject, - textures: Vec, + textures: Vec, ) -> error::Result> { let mut luts = FastHashMap::default(); @@ -315,7 +315,7 @@ impl FilterChainMetal { cmd: &ProtocolObject, options: Option<&FilterChainOptionsMetal>, ) -> error::Result { - let (passes, semantics) = compile_passes(preset.shaders, &preset.textures)?; + let (passes, semantics) = compile_passes(preset.passes, &preset.textures)?; let filters = Self::init_passes(&device, passes, &semantics)?; @@ -352,7 +352,7 @@ impl FilterChainMetal { common: FilterCommon { luts, samplers, - config: RuntimeParameters::new(preset.shader_count as usize, preset.parameters), + config: RuntimeParameters::new(preset.pass_count as usize, preset.parameters), draw_quad, device, output_textures, diff --git a/librashader-runtime-mtl/src/filter_pass.rs b/librashader-runtime-mtl/src/filter_pass.rs index 1eab383..538f5aa 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::ShaderPassMeta; +use librashader_presets::PassMeta; 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 meta: ShaderPassMeta, + pub meta: PassMeta, pub graphics_pipeline: MetalGraphicsPipeline, } @@ -177,7 +177,7 @@ impl FilterPassMeta for FilterPass { self.source.format } - fn meta(&self) -> &ShaderPassMeta { + fn meta(&self) -> &PassMeta { &self.meta } } diff --git a/librashader-runtime-vk/src/filter_chain.rs b/librashader-runtime-vk/src/filter_chain.rs index af42f9c..0d4badd 100644 --- a/librashader-runtime-vk/src/filter_chain.rs +++ b/librashader-runtime-vk/src/filter_chain.rs @@ -250,7 +250,7 @@ impl Drop for FrameResiduals { mod compile { use super::*; - use librashader_pack::ShaderPassData; + use librashader_pack::PassResource; #[cfg(not(feature = "stable"))] pub type ShaderPassMeta = @@ -262,8 +262,8 @@ mod compile { >; pub fn compile_passes( - shaders: Vec, - textures: &[TextureData], + shaders: Vec, + textures: &[TextureResource], disable_cache: bool, ) -> Result<(Vec, ShaderSemantics), FilterChainError> { let (passes, semantics) = if !disable_cache { @@ -284,7 +284,7 @@ mod compile { } use compile::{compile_passes, ShaderPassMeta}; -use librashader_pack::{ShaderPresetPack, TextureData}; +use librashader_pack::{ShaderPresetPack, TextureResource}; use librashader_runtime::parameters::RuntimeParameters; impl FilterChainVulkan { @@ -415,7 +415,7 @@ impl FilterChainVulkan { FilterChainError: From, { let disable_cache = options.map_or(false, |o| o.disable_cache); - let (passes, semantics) = compile_passes(preset.shaders, &preset.textures, disable_cache)?; + let (passes, semantics) = compile_passes(preset.passes, &preset.textures, disable_cache)?; let device = vulkan.try_into().map_err(From::from)?; @@ -466,7 +466,7 @@ impl FilterChainVulkan { common: FilterCommon { luts, samplers, - config: RuntimeParameters::new(preset.shader_count as usize, preset.parameters), + config: RuntimeParameters::new(preset.pass_count as usize, preset.parameters), draw_quad: DrawQuad::new(&device.device, &device.alloc)?, device: device.device.clone(), output_textures, @@ -559,7 +559,7 @@ impl FilterChainVulkan { fn load_luts( vulkan: &VulkanObjects, command_buffer: vk::CommandBuffer, - textures: Vec, + textures: Vec, ) -> error::Result> { let mut luts = FastHashMap::default(); let textures = textures diff --git a/librashader-runtime-vk/src/filter_pass.rs b/librashader-runtime-vk/src/filter_pass.rs index f5513a0..dc3b447 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::ShaderPassMeta; +use librashader_presets::PassMeta; 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 meta: ShaderPassMeta, + pub meta: PassMeta, pub graphics_pipeline: VulkanGraphicsPipeline, pub frames_in_flight: u32, } @@ -78,7 +78,7 @@ impl FilterPassMeta for FilterPass { self.source.format } - fn meta(&self) -> &ShaderPassMeta { + fn meta(&self) -> &PassMeta { &self.meta } } diff --git a/librashader-runtime-wgpu/src/filter_chain.rs b/librashader-runtime-wgpu/src/filter_chain.rs index 9022d84..f53d43a 100644 --- a/librashader-runtime-wgpu/src/filter_chain.rs +++ b/librashader-runtime-wgpu/src/filter_chain.rs @@ -40,7 +40,7 @@ use crate::texture::{InputImage, OwnedImage}; mod compile { use super::*; - use librashader_pack::{ShaderPassData, TextureData}; + use librashader_pack::{PassResource, TextureResource}; #[cfg(not(feature = "stable"))] pub type ShaderPassMeta = @@ -51,8 +51,8 @@ mod compile { ShaderPassArtifact + Send>>; pub fn compile_passes( - shaders: Vec, - textures: &[TextureData], + shaders: Vec, + textures: &[TextureResource], ) -> Result<(Vec, ShaderSemantics), FilterChainError> { let (passes, semantics) = WGSL::compile_preset_passes::< SpirvCompilation, @@ -64,7 +64,7 @@ mod compile { } use compile::{compile_passes, ShaderPassMeta}; -use librashader_pack::{ShaderPresetPack, TextureData}; +use librashader_pack::{ShaderPresetPack, TextureResource}; use librashader_runtime::parameters::RuntimeParameters; /// A wgpu filter chain. @@ -176,7 +176,7 @@ impl FilterChainWgpu { cmd: &mut wgpu::CommandEncoder, options: Option<&FilterChainOptionsWgpu>, ) -> error::Result { - let (passes, semantics) = compile_passes(preset.shaders, &preset.textures)?; + let (passes, semantics) = compile_passes(preset.passes, &preset.textures)?; // cache is opt-in for wgpu, not opt-out because of feature requirements. let disable_cache = options.map_or(true, |o| !o.enable_cache); @@ -234,7 +234,7 @@ impl FilterChainWgpu { common: FilterCommon { luts, samplers, - config: RuntimeParameters::new(preset.shader_count as usize, preset.parameters), + config: RuntimeParameters::new(preset.pass_count as usize, preset.parameters), draw_quad, device, queue, @@ -258,7 +258,7 @@ impl FilterChainWgpu { cmd: &mut wgpu::CommandEncoder, mipmapper: &mut MipmapGen, sampler_set: &SamplerSet, - textures: Vec, + textures: Vec, ) -> error::Result> { let mut luts = FastHashMap::default(); diff --git a/librashader-runtime-wgpu/src/filter_pass.rs b/librashader-runtime-wgpu/src/filter_pass.rs index 399eba5..09f5358 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::ShaderPassMeta; +use librashader_presets::PassMeta; use librashader_reflect::reflect::semantics::{ BindingStage, MemberOffset, TextureBinding, UniformBinding, }; @@ -34,7 +34,7 @@ pub struct FilterPass { >, pub uniform_bindings: FastHashMap, pub source: ShaderSource, - pub meta: ShaderPassMeta, + pub meta: PassMeta, pub graphics_pipeline: WgpuGraphicsPipeline, } @@ -255,7 +255,7 @@ impl FilterPassMeta for FilterPass { self.source.format } - fn meta(&self) -> &ShaderPassMeta { + fn meta(&self) -> &PassMeta { &self.meta } } diff --git a/librashader-runtime/src/filter_pass.rs b/librashader-runtime/src/filter_pass.rs index e772b49..f68ed0d 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::ShaderPassMeta; +use librashader_presets::PassMeta; /// Trait for metadata about a filter pass. pub trait FilterPassMeta { @@ -7,7 +7,7 @@ pub trait FilterPassMeta { fn framebuffer_format(&self) -> ImageFormat; /// Gets a reference to the filter pass config. - fn meta(&self) -> &ShaderPassMeta; + fn meta(&self) -> &PassMeta; /// Gets the format of the filter pass framebuffer. #[inline(always)] diff --git a/librashader-runtime/src/image.rs b/librashader-runtime/src/image.rs index 81464d6..4c735b7 100644 --- a/librashader-runtime/src/image.rs +++ b/librashader-runtime/src/image.rs @@ -4,7 +4,7 @@ use std::marker::PhantomData; use image::error::{LimitError, LimitErrorKind}; use image::DynamicImage; -use librashader_pack::{TextureBuffer, TextureData}; +use librashader_pack::{TextureBuffer, TextureResource}; use librashader_presets::TextureMeta; use std::path::Path; @@ -117,7 +117,7 @@ impl Image

{ } } -/// Loaded texture data in the proper pixel format from a [`TextureData`]. +/// Loaded texture data in the proper pixel format from a [`TextureResource`]. pub struct LoadedTexture { /// The loaded image data pub image: Image

, @@ -127,7 +127,10 @@ pub struct LoadedTexture { impl LoadedTexture

{ /// Load the texture with the given UV direction and subpixel ordering. - pub fn from_texture(texture: TextureData, direction: UVDirection) -> Result { + pub fn from_texture( + texture: TextureResource, + direction: UVDirection, + ) -> Result { Ok(LoadedTexture { meta: texture.meta, image: Image::load_from_buffer(texture.data, direction)?, diff --git a/librashader/src/lib.rs b/librashader/src/lib.rs index 6c8a0c6..4218c28 100644 --- a/librashader/src/lib.rs +++ b/librashader/src/lib.rs @@ -77,7 +77,7 @@ pub mod presets { preset: &ShaderPreset, ) -> Result, PreprocessError> { let iters: Result>, PreprocessError> = preset - .shaders + .passes .iter() .map(|s| { ShaderSource::load(&s.path) @@ -131,7 +131,7 @@ pub mod preprocess { /// pub fn compile_preset(preset: ShaderPreset) -> Result<(Vec, ShaderSemantics), Box> /// { /// let (passes, semantics) = SPIRV::compile_preset_passes::>( -/// preset.shaders, &preset.textures)?; +/// preset.passes, &preset.textures)?; /// Ok((passes, semantics)) /// } /// } diff --git a/librashader/tests/reflect.rs b/librashader/tests/reflect.rs index 23b3119..b048273 100644 --- a/librashader/tests/reflect.rs +++ b/librashader/tests/reflect.rs @@ -14,9 +14,9 @@ use librashader::reflect::FromCompilation; use librashader::reflect::OutputTarget; use librashader::reflect::SpirvCompilation; -use librashader_pack::{LoadableResource, ShaderPassData}; +use librashader_pack::{LoadableResource, PassResource}; use librashader_preprocess::PreprocessError; -use librashader_presets::ShaderPassMeta; +use librashader_presets::PassMeta; use once_cell::sync::Lazy; static ALL_SLANG_PRESETS: Lazy>> = @@ -57,7 +57,7 @@ fn collect_all_loadable_slang_presets() -> Vec<(PathBuf, ShaderPreset)> { let mut presets = collect_all_slang_presets(false); presets.retain(|(_, preset)| { !preset - .shaders + .passes .par_iter() .any(|shader| ShaderSource::load(&shader.path).is_err()) }); @@ -70,7 +70,7 @@ pub fn preprocess_all_slang_presets_parsed() { let presets = collect_all_slang_presets(true); for (path, preset) in presets { - preset.shaders.into_par_iter().for_each(|shader| { + preset.passes.into_par_iter().for_each(|shader| { if let Err(e) = ShaderSource::load(&shader.path) { #[cfg(not(feature = "github-ci"))] eprintln!( @@ -143,11 +143,11 @@ where ); let shader_pass_data = preset - .shaders + .passes .par_iter() .map(|p| { ( - ShaderPassMeta::load(&p.path).map(|data| ShaderPassData { + PassMeta::load(&p.path).map(|data| PassResource { meta: p.meta.clone(), data, }), @@ -169,7 +169,7 @@ where }; e }) - .collect::, PreprocessError>>(); + .collect::, PreprocessError>>(); let Ok(shader_pass_data) = shader_pass_data else { return;