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`
This commit is contained in:
chyyran 2024-10-02 17:49:30 -04:00 committed by Ronny Chan
parent f189468f6d
commit 3ee5e66c0d
28 changed files with 134 additions and 130 deletions

View file

@ -1,6 +1,6 @@
use crate::error; use crate::error;
use librashader::presets::{ShaderPassConfig, ShaderPreset}; use librashader::presets::{PassConfig, ShaderPreset};
use librashader::reflect::semantics::ShaderSemantics; use librashader::reflect::semantics::ShaderSemantics;
use librashader::reflect::targets::SPIRV; use librashader::reflect::targets::SPIRV;
use librashader::reflect::{CompileShader, ReflectShader, ShaderCompilerOutput, ShaderReflection}; use librashader::reflect::{CompileShader, ReflectShader, ShaderCompilerOutput, ShaderReflection};
@ -21,7 +21,7 @@ pub(crate) struct LookupTexture {
pub(crate) struct PassReflection { pub(crate) struct PassReflection {
reflection: ShaderReflection, reflection: ShaderReflection,
config: ShaderPassConfig, config: PassConfig,
spirv: ShaderCompilerOutput<Vec<u32>>, spirv: ShaderCompilerOutput<Vec<u32>>,
} }
pub(crate) struct FilterReflection { pub(crate) struct FilterReflection {
@ -35,7 +35,7 @@ impl FilterReflection {
preset: ShaderPreset, preset: ShaderPreset,
direction: UVDirection, direction: UVDirection,
) -> Result<FilterReflection, error::LibrashaderError> { ) -> Result<FilterReflection, error::LibrashaderError> {
let (passes, textures) = (preset.shaders, preset.textures); let (passes, textures) = (preset.passes, preset.textures);
let (passes, semantics) = librashader::reflect::helper::compile_preset_passes::< let (passes, semantics) = librashader::reflect::helper::compile_preset_passes::<
Glslang, Glslang,

View file

@ -509,7 +509,7 @@ pub fn main() -> Result<(), anyhow::Error> {
let PresetArgs { preset, wildcards } = preset; let PresetArgs { preset, wildcards } = preset;
let preset = get_shader_preset(preset, wildcards)?; 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")); return Err(anyhow!("Invalid pass index for the preset"));
}; };

View file

@ -6,7 +6,7 @@
//! //!
use image::{ImageError, RgbaImage}; use image::{ImageError, RgbaImage};
use librashader_preprocess::{PreprocessError, ShaderSource}; use librashader_preprocess::{PreprocessError, ShaderSource};
use librashader_presets::{ParameterMeta, ShaderPassMeta, ShaderPreset, TextureMeta}; use librashader_presets::{ParameterMeta, PassMeta, ShaderPreset, TextureMeta};
use std::path::Path; use std::path::Path;
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
@ -49,7 +49,7 @@ impl From<RgbaImage> for TextureBuffer {
/// A resource for a shader preset, fully loaded into memory. /// A resource for a shader preset, fully loaded into memory.
#[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 ShaderPresetResource<M: LoadableResource> { pub struct LoadedResource<M: LoadableResource> {
/// The fully qualified path to the texture. /// The fully qualified path to the texture.
pub data: M::ResourceType, pub data: M::ResourceType,
/// Meta information about the texture. /// Meta information about the texture.
@ -66,7 +66,7 @@ pub trait LoadableResource {
fn load(path: &Path) -> Result<Self::ResourceType, Self::Error>; fn load(path: &Path) -> Result<Self::ResourceType, Self::Error>;
} }
impl LoadableResource for ShaderPassMeta { impl LoadableResource for PassMeta {
type ResourceType = ShaderSource; type ResourceType = ShaderSource;
type Error = PreprocessError; type Error = PreprocessError;
@ -84,9 +84,11 @@ impl LoadableResource for TextureMeta {
} }
} }
/// The configuration for a single shader pass. /// The loaded resource information for the source code of a shader pass.
pub type ShaderPassData = ShaderPresetResource<ShaderPassMeta>; pub type PassResource = LoadedResource<PassMeta>;
pub type TextureData = ShaderPresetResource<TextureMeta>;
/// The loaded texture resource for a shader preset.
pub type TextureResource = LoadedResource<TextureMeta>;
/// A fully loaded-in-memory shader preset, with all paths resolved to data. /// A fully loaded-in-memory shader preset, with all paths resolved to data.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
@ -98,13 +100,13 @@ pub struct ShaderPresetPack {
pub feedback_pass: i32, pub feedback_pass: i32,
/// The number of shaders enabled in the filter chain. /// 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. // Everything is in Vecs because the expect number of values is well below 64.
/// Preset information for each shader. /// Preset information for each shader.
pub shaders: Vec<ShaderPassData>, pub passes: Vec<PassResource>,
/// Preset information for each texture. /// Preset information for each texture.
pub textures: Vec<TextureData>, pub textures: Vec<TextureResource>,
/// Preset information for each user parameter. /// Preset information for each user parameter.
pub parameters: Vec<ParameterMeta>, pub parameters: Vec<ParameterMeta>,
@ -119,7 +121,7 @@ impl ShaderPresetPack {
E: Send, E: Send,
{ {
#[cfg(not(target_arch = "wasm32"))] #[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")] #[cfg(target_arch = "wasm32")]
let shaders_iter = preset.shaders.into_iter(); let shaders_iter = preset.shaders.into_iter();
@ -134,11 +136,11 @@ impl ShaderPresetPack {
#[cfg(feature = "parse_legacy_glsl")] #[cfg(feature = "parse_legacy_glsl")]
feedback_pass: preset.feedback_pass, feedback_pass: preset.feedback_pass,
shader_count: preset.shader_count, pass_count: preset.pass_count,
shaders: shaders_iter passes: shaders_iter
.map(|v| { .map(|v| {
Ok::<_, E>(ShaderPassData { Ok::<_, E>(PassResource {
data: ShaderPassMeta::load(v.path.as_path())?, data: PassMeta::load(v.path.as_path())?,
meta: v.meta, meta: v.meta,
}) })
}) })
@ -146,7 +148,7 @@ impl ShaderPresetPack {
textures: textures_iter textures: textures_iter
.into_par_iter() .into_par_iter()
.map(|t| { .map(|t| {
Ok::<_, E>(TextureData { Ok::<_, E>(TextureResource {
data: TextureMeta::load(t.path.as_path())?, data: TextureMeta::load(t.path.as_path())?,
meta: t.meta, meta: t.meta,
}) })

View file

@ -1,8 +1,7 @@
use crate::parse::remove_if; use crate::parse::remove_if;
use crate::parse::value::Value; use crate::parse::value::Value;
use crate::{ use crate::{
ParameterMeta, Scale2D, Scaling, ShaderPassConfig, ShaderPassMeta, ShaderPreset, TextureConfig, ParameterMeta, PassConfig, PassMeta, Scale2D, Scaling, ShaderPreset, TextureConfig, TextureMeta,
TextureMeta,
}; };
use vec_extract_if_polyfill::MakeExtractIf; use vec_extract_if_polyfill::MakeExtractIf;
@ -118,9 +117,9 @@ pub fn resolve_values(mut values: Vec<Value>) -> ShaderPreset {
scale_y = scale; scale_y = scale;
} }
let shader = ShaderPassConfig { let shader = PassConfig {
path: name, path: name,
meta: ShaderPassMeta { meta: PassMeta {
id, id,
alias: shader_values.iter().find_map(|f| match f { alias: shader_values.iter().find_map(|f| match f {
Value::Alias(_, value) => Some(value.clone()), Value::Alias(_, value) => Some(value.clone()),
@ -189,8 +188,8 @@ pub fn resolve_values(mut values: Vec<Value>) -> ShaderPreset {
ShaderPreset { ShaderPreset {
#[cfg(feature = "parse_legacy_glsl")] #[cfg(feature = "parse_legacy_glsl")]
feedback_pass, feedback_pass,
shader_count, pass_count: shader_count,
shaders, passes: shaders,
textures, textures,
parameters, parameters,
} }

View file

@ -6,7 +6,7 @@ use std::path::PathBuf;
use std::str::FromStr; use std::str::FromStr;
/// The configuration for a single shader pass. /// The configuration for a single shader pass.
pub type ShaderPassConfig = PathReference<ShaderPassMeta>; pub type PassConfig = PathReference<PassMeta>;
/// Configuration options for a lookup texture used in the shader. /// Configuration options for a lookup texture used in the shader.
pub type TextureConfig = PathReference<TextureMeta>; pub type TextureConfig = PathReference<TextureMeta>;
@ -24,7 +24,7 @@ pub struct PathReference<M> {
/// Meta information about a shader pass. /// Meta information about a shader pass.
#[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 ShaderPassMeta { pub struct PassMeta {
/// The index of the shader pass relative to its parent preset. /// The index of the shader pass relative to its parent preset.
pub id: i32, pub id: i32,
/// The alias of the shader pass if available. /// The alias of the shader pass if available.
@ -45,7 +45,7 @@ pub struct ShaderPassMeta {
pub scaling: Scale2D, pub scaling: Scale2D,
} }
impl ShaderPassMeta { impl PassMeta {
/// 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)]
@ -204,10 +204,10 @@ pub struct ShaderPreset {
pub feedback_pass: i32, pub feedback_pass: i32,
/// The number of shaders enabled in the filter chain. /// 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. // Everything is in Vecs because the expect number of values is well below 64.
/// Preset information for each shader. /// Preset information for each shader.
pub shaders: Vec<ShaderPassConfig>, pub passes: Vec<PassConfig>,
/// Preset information for each texture. /// Preset information for each texture.
pub textures: Vec<TextureConfig>, pub textures: Vec<TextureConfig>,

View file

@ -34,7 +34,7 @@
//! pub fn compile_preset(preset: ShaderPreset) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), Box<dyn Error>> //! pub fn compile_preset(preset: ShaderPreset) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), Box<dyn Error>>
//! { //! {
//! let (passes, semantics) = SPIRV::compile_preset_passes::<SpirvCompilation, SpirvCross, Box<dyn Error>>( //! let (passes, semantics) = SPIRV::compile_preset_passes::<SpirvCompilation, SpirvCross, Box<dyn Error>>(
//! preset.shaders, &preset.textures)?; //! preset.passes, &preset.textures)?;
//! Ok((passes, semantics)) //! Ok((passes, semantics))
//! } //! }
//! ``` //! ```

View file

@ -6,9 +6,9 @@ use crate::reflect::semantics::{
Semantic, ShaderSemantics, TextureSemantics, UniformSemantic, UniqueSemantics, Semantic, ShaderSemantics, TextureSemantics, UniformSemantic, UniqueSemantics,
}; };
use librashader_common::map::{FastHashMap, ShortString}; use librashader_common::map::{FastHashMap, ShortString};
use librashader_pack::ShaderPassData; use librashader_pack::PassResource;
use librashader_preprocess::{PreprocessError, ShaderSource}; 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. /// 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. /// This allows a runtime to not name the backing type of the compiled artifact if not necessary.
pub type ShaderPassArtifact<T> = (ShaderPassMeta, ShaderSource, CompilerBackend<T>); pub type ShaderPassArtifact<T> = (PassMeta, ShaderSource, CompilerBackend<T>);
impl<T: OutputTarget> CompilePresetTarget for T {} impl<T: OutputTarget> CompilePresetTarget for T {}
@ -38,7 +38,7 @@ pub trait CompilePresetTarget: OutputTarget {
/// Compile passes of a shader preset given the applicable /// Compile passes of a shader preset given the applicable
/// shader output target, compilation type, and resulting error. /// shader output target, compilation type, and resulting error.
fn compile_preset_passes<'a, I, R, E>( fn compile_preset_passes<'a, I, R, E>(
passes: Vec<ShaderPassData>, passes: Vec<PassResource>,
textures: impl Iterator<Item = &'a TextureMeta>, textures: impl Iterator<Item = &'a TextureMeta>,
) -> Result< ) -> Result<
( (
@ -63,7 +63,7 @@ pub trait CompilePresetTarget: OutputTarget {
/// Compile passes of a shader preset given the applicable /// Compile passes of a shader preset given the applicable
/// shader output target, compilation type, and resulting error. /// shader output target, compilation type, and resulting error.
fn compile_preset_passes<'a, T, I, R, E>( fn compile_preset_passes<'a, T, I, R, E>(
passes: Vec<ShaderPassData>, passes: Vec<PassResource>,
textures: impl Iterator<Item = &'a TextureMeta>, textures: impl Iterator<Item = &'a TextureMeta>,
) -> Result< ) -> Result<
( (
@ -103,7 +103,7 @@ where
} }
Ok::<_, E>((shader.meta, source, reflect)) Ok::<_, E>((shader.meta, source, reflect))
}) })
.collect::<Result<Vec<(ShaderPassMeta, ShaderSource, CompilerBackend<_>)>, E>>()?; .collect::<Result<Vec<(PassMeta, ShaderSource, CompilerBackend<_>)>, E>>()?;
for (meta, source, _) in &passes { for (meta, source, _) in &passes {
insert_pass_semantics( insert_pass_semantics(
@ -232,7 +232,7 @@ impl ShaderSemantics {
Default::default(); Default::default();
let config = preset let config = preset
.shaders .passes
.get(index) .get(index)
.ok_or_else(|| PreprocessError::InvalidStage)?; .ok_or_else(|| PreprocessError::InvalidStage)?;

View file

@ -75,7 +75,7 @@ pub(crate) struct FilterCommon {
mod compile { mod compile {
use super::*; use super::*;
use librashader_pack::{ShaderPassData, TextureData}; use librashader_pack::{PassResource, TextureResource};
#[cfg(not(feature = "stable"))] #[cfg(not(feature = "stable"))]
pub type ShaderPassMeta = pub type ShaderPassMeta =
@ -87,8 +87,8 @@ mod compile {
>; >;
pub fn compile_passes( pub fn compile_passes(
shaders: Vec<ShaderPassData>, shaders: Vec<PassResource>,
textures: &[TextureData], textures: &[TextureResource],
disable_cache: bool, disable_cache: bool,
) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> { ) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> {
let (passes, semantics) = if !disable_cache { let (passes, semantics) = if !disable_cache {
@ -109,7 +109,7 @@ mod compile {
} }
use compile::{compile_passes, ShaderPassMeta}; use compile::{compile_passes, ShaderPassMeta};
use librashader_pack::{ShaderPresetPack, TextureData}; use librashader_pack::{ShaderPresetPack, TextureResource};
use librashader_runtime::parameters::RuntimeParameters; use librashader_runtime::parameters::RuntimeParameters;
impl FilterChainD3D11 { impl FilterChainD3D11 {
@ -193,7 +193,7 @@ impl FilterChainD3D11 {
) -> error::Result<FilterChainD3D11> { ) -> error::Result<FilterChainD3D11> {
let disable_cache = options.map_or(false, |o| o.disable_cache); 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)?; let samplers = SamplerSet::new(device)?;
@ -237,7 +237,7 @@ impl FilterChainD3D11 {
_device: device.clone(), _device: device.clone(),
immediate_context, 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), disable_mipmaps: options.map_or(false, |o| o.force_no_mipmaps),
luts, luts,
samplers, samplers,
@ -399,7 +399,7 @@ impl FilterChainD3D11 {
fn load_luts( fn load_luts(
device: &ID3D11Device, device: &ID3D11Device,
context: &ID3D11DeviceContext, context: &ID3D11DeviceContext,
textures: Vec<TextureData>, textures: Vec<TextureResource>,
) -> error::Result<FastHashMap<usize, LutTexture>> { ) -> error::Result<FastHashMap<usize, LutTexture>> {
let mut luts = FastHashMap::default(); let mut luts = FastHashMap::default();
let textures = textures let textures = textures

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::ShaderPassMeta; use librashader_presets::PassMeta;
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 meta: ShaderPassMeta, pub meta: PassMeta,
} }
// 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,7 +90,7 @@ impl FilterPassMeta for FilterPass {
self.source.format self.source.format
} }
fn meta(&self) -> &ShaderPassMeta { fn meta(&self) -> &PassMeta {
&self.meta &self.meta
} }
} }

View file

@ -175,7 +175,7 @@ impl Drop for FrameResiduals {
mod compile { mod compile {
use super::*; use super::*;
use librashader_pack::ShaderPassData; use librashader_pack::PassResource;
#[cfg(not(feature = "stable"))] #[cfg(not(feature = "stable"))]
pub type DxilShaderPassMeta = pub type DxilShaderPassMeta =
@ -187,8 +187,8 @@ mod compile {
>; >;
pub fn compile_passes_dxil( pub fn compile_passes_dxil(
shaders: Vec<ShaderPassData>, shaders: Vec<PassResource>,
textures: &[TextureData], textures: &[TextureResource],
disable_cache: bool, disable_cache: bool,
) -> Result<(Vec<DxilShaderPassMeta>, ShaderSemantics), FilterChainError> { ) -> Result<(Vec<DxilShaderPassMeta>, ShaderSemantics), FilterChainError> {
let (passes, semantics) = if !disable_cache { let (passes, semantics) = if !disable_cache {
@ -217,8 +217,8 @@ mod compile {
>; >;
pub fn compile_passes_hlsl( pub fn compile_passes_hlsl(
shaders: Vec<ShaderPassData>, shaders: Vec<PassResource>,
textures: &[TextureData], textures: &[TextureResource],
disable_cache: bool, disable_cache: bool,
) -> Result<(Vec<HlslShaderPassMeta>, ShaderSemantics), FilterChainError> { ) -> Result<(Vec<HlslShaderPassMeta>, ShaderSemantics), FilterChainError> {
let (passes, semantics) = if !disable_cache { let (passes, semantics) = if !disable_cache {
@ -240,7 +240,7 @@ mod compile {
use crate::resource::OutlivesFrame; use crate::resource::OutlivesFrame;
use compile::{compile_passes_dxil, compile_passes_hlsl, DxilShaderPassMeta, HlslShaderPassMeta}; 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; use librashader_runtime::parameters::RuntimeParameters;
impl FilterChainD3D12 { impl FilterChainD3D12 {
@ -335,14 +335,14 @@ impl FilterChainD3D12 {
cmd: &ID3D12GraphicsCommandList, cmd: &ID3D12GraphicsCommandList,
options: Option<&FilterChainOptionsD3D12>, options: Option<&FilterChainOptionsD3D12>,
) -> error::Result<FilterChainD3D12> { ) -> error::Result<FilterChainD3D12> {
let shader_count = preset.shaders.len(); let shader_count = preset.passes.len();
let lut_count = preset.textures.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 disable_cache = options.map_or(false, |o| o.disable_cache);
let (passes, semantics) = 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 (hlsl_passes, _) = compile_passes_hlsl(shader_copy, &preset.textures, disable_cache)?;
let samplers = SamplerSet::new(device)?; let samplers = SamplerSet::new(device)?;
@ -436,7 +436,7 @@ impl FilterChainD3D12 {
mipmap_gen, mipmap_gen,
root_signature, root_signature,
draw_quad, draw_quad,
config: RuntimeParameters::new(preset.shader_count as usize, preset.parameters), config: RuntimeParameters::new(preset.pass_count as usize, preset.parameters),
history_textures, history_textures,
}, },
staging_heap, staging_heap,
@ -461,7 +461,7 @@ impl FilterChainD3D12 {
staging_heap: &mut D3D12DescriptorHeap<CpuStagingHeap>, staging_heap: &mut D3D12DescriptorHeap<CpuStagingHeap>,
mipmap_heap: &mut D3D12DescriptorHeap<ResourceWorkHeap>, mipmap_heap: &mut D3D12DescriptorHeap<ResourceWorkHeap>,
gc: &mut FrameResiduals, gc: &mut FrameResiduals,
textures: Vec<TextureData>, textures: Vec<TextureResource>,
) -> error::Result<FastHashMap<usize, LutTexture>> { ) -> error::Result<FastHashMap<usize, LutTexture>> {
// use separate mipgen to load luts. // use separate mipgen to load luts.
let mipmap_gen = D3D12MipmapGen::new(device, true)?; let mipmap_gen = D3D12MipmapGen::new(device, true)?;

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::ShaderPassMeta; use librashader_presets::PassMeta;
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) meta: ShaderPassMeta, pub(crate) meta: PassMeta,
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,7 +77,7 @@ impl FilterPassMeta for FilterPass {
self.source.format self.source.format
} }
fn meta(&self) -> &ShaderPassMeta { fn meta(&self) -> &PassMeta {
&self.meta &self.meta
} }
} }

View file

@ -63,7 +63,7 @@ pub struct FilterChainD3D9 {
mod compile { mod compile {
use super::*; use super::*;
use librashader_pack::{ShaderPassData, TextureData}; use librashader_pack::{PassResource, TextureResource};
#[cfg(not(feature = "stable"))] #[cfg(not(feature = "stable"))]
pub type ShaderPassMeta = pub type ShaderPassMeta =
@ -75,8 +75,8 @@ mod compile {
>; >;
pub fn compile_passes( pub fn compile_passes(
shaders: Vec<ShaderPassData>, shaders: Vec<PassResource>,
textures: &[TextureData], textures: &[TextureResource],
disable_cache: bool, disable_cache: bool,
) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> { ) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> {
let (passes, semantics) = if !disable_cache { let (passes, semantics) = if !disable_cache {
@ -97,7 +97,7 @@ mod compile {
} }
use compile::{compile_passes, ShaderPassMeta}; use compile::{compile_passes, ShaderPassMeta};
use librashader_pack::{ShaderPresetPack, TextureData}; use librashader_pack::{ShaderPresetPack, TextureResource};
use librashader_runtime::parameters::RuntimeParameters; use librashader_runtime::parameters::RuntimeParameters;
impl FilterChainD3D9 { impl FilterChainD3D9 {
@ -189,7 +189,7 @@ impl FilterChainD3D9 {
fn load_luts( fn load_luts(
device: &IDirect3DDevice9, device: &IDirect3DDevice9,
textures: Vec<TextureData>, textures: Vec<TextureResource>,
) -> error::Result<FastHashMap<usize, LutTexture>> { ) -> error::Result<FastHashMap<usize, LutTexture>> {
let mut luts = FastHashMap::default(); let mut luts = FastHashMap::default();
let images = textures let images = textures
@ -236,7 +236,7 @@ impl FilterChainD3D9 {
) -> error::Result<FilterChainD3D9> { ) -> error::Result<FilterChainD3D9> {
let disable_cache = options.map_or(false, |o| o.disable_cache); 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()?; let samplers = SamplerSet::new()?;
@ -275,7 +275,7 @@ impl FilterChainD3D9 {
history_framebuffers, history_framebuffers,
common: FilterCommon { common: FilterCommon {
d3d9: device.clone(), 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), disable_mipmaps: options.map_or(false, |o| o.force_no_mipmaps),
luts, luts,
samplers, samplers,

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::ShaderPassMeta; use librashader_presets::PassMeta;
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 meta: ShaderPassMeta, pub meta: PassMeta,
pub uniform_storage: D3D9UniformStorage, pub uniform_storage: D3D9UniformStorage,
pub gl_halfpixel: Option<RegisterAssignment>, pub gl_halfpixel: Option<RegisterAssignment>,
} }
@ -38,7 +38,7 @@ impl FilterPassMeta for FilterPass {
self.source.format self.source.format
} }
fn meta(&self) -> &ShaderPassMeta { fn meta(&self) -> &PassMeta {
&self.meta &self.meta
} }
} }

View file

@ -21,7 +21,7 @@ use librashader_reflect::reflect::semantics::{ShaderSemantics, UniformMeta};
use glow::HasContext; use glow::HasContext;
use librashader_cache::CachedCompilation; use librashader_cache::CachedCompilation;
use librashader_common::map::FastHashMap; 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::cross::SpirvCross;
use librashader_reflect::reflect::presets::{CompilePresetTarget, ShaderPassArtifact}; use librashader_reflect::reflect::presets::{CompilePresetTarget, ShaderPassArtifact};
use librashader_reflect::reflect::ReflectShader; use librashader_reflect::reflect::ReflectShader;
@ -108,8 +108,8 @@ mod compile {
>; >;
pub fn compile_passes( pub fn compile_passes(
shaders: Vec<ShaderPassData>, shaders: Vec<PassResource>,
textures: &[TextureData], textures: &[TextureResource],
disable_cache: bool, disable_cache: bool,
) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> { ) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> {
let (passes, semantics) = if !disable_cache { let (passes, semantics) = if !disable_cache {
@ -140,7 +140,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
options: Option<&FilterChainOptionsGL>, options: Option<&FilterChainOptionsGL>,
) -> error::Result<Self> { ) -> error::Result<Self> {
let disable_cache = options.map_or(false, |o| o.disable_cache); 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( let version = options.map_or_else(
|| gl_get_version(&context), || gl_get_version(&context),
|o| gl_u16_to_version(&context, o.glsl_version), |o| gl_u16_to_version(&context, o.glsl_version),
@ -197,7 +197,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
history_framebuffers, history_framebuffers,
draw_quad, draw_quad,
common: FilterCommon { 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), disable_mipmaps: options.map_or(false, |o| o.force_no_mipmaps),
luts, luts,
samplers, samplers,

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::ShaderPassMeta; use librashader_presets::PassMeta;
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 meta: ShaderPassMeta, pub meta: PassMeta,
} }
impl TextureInput for InputTexture { impl TextureInput for InputTexture {
@ -162,7 +162,7 @@ impl<T: GLInterface> FilterPassMeta for FilterPass<T> {
self.source.format self.source.format
} }
fn meta(&self) -> &ShaderPassMeta { fn meta(&self) -> &PassMeta {
&self.meta &self.meta
} }
} }

View file

@ -4,7 +4,7 @@ use crate::gl::LoadLut;
use crate::texture::InputTexture; use crate::texture::InputTexture;
use glow::{HasContext, PixelUnpackData}; use glow::{HasContext, PixelUnpackData};
use librashader_common::map::FastHashMap; use librashader_common::map::FastHashMap;
use librashader_pack::TextureData; use librashader_pack::TextureResource;
use librashader_runtime::image::{ImageError, LoadedTexture, UVDirection}; use librashader_runtime::image::{ImageError, LoadedTexture, UVDirection};
use librashader_runtime::scaling::MipmapSize; use librashader_runtime::scaling::MipmapSize;
use rayon::prelude::*; use rayon::prelude::*;
@ -14,7 +14,7 @@ pub struct Gl3LutLoad;
impl LoadLut for Gl3LutLoad { impl LoadLut for Gl3LutLoad {
fn load_luts( fn load_luts(
context: &glow::Context, context: &glow::Context,
textures: Vec<TextureData>, textures: Vec<TextureResource>,
) -> Result<FastHashMap<usize, InputTexture>> { ) -> Result<FastHashMap<usize, InputTexture>> {
let mut luts = FastHashMap::default(); let mut luts = FastHashMap::default();
let pixel_unpack = unsafe { context.get_parameter_i32(glow::PIXEL_UNPACK_BUFFER_BINDING) }; let pixel_unpack = unsafe { context.get_parameter_i32(glow::PIXEL_UNPACK_BUFFER_BINDING) };

View file

@ -4,7 +4,7 @@ use crate::gl::LoadLut;
use crate::texture::InputTexture; use crate::texture::InputTexture;
use glow::{HasContext, PixelUnpackData}; use glow::{HasContext, PixelUnpackData};
use librashader_common::map::FastHashMap; use librashader_common::map::FastHashMap;
use librashader_pack::TextureData; use librashader_pack::TextureResource;
use librashader_runtime::image::{ImageError, LoadedTexture, UVDirection}; use librashader_runtime::image::{ImageError, LoadedTexture, UVDirection};
use librashader_runtime::scaling::MipmapSize; use librashader_runtime::scaling::MipmapSize;
use rayon::prelude::*; use rayon::prelude::*;
@ -13,7 +13,7 @@ pub struct Gl46LutLoad;
impl LoadLut for Gl46LutLoad { impl LoadLut for Gl46LutLoad {
fn load_luts( fn load_luts(
context: &glow::Context, context: &glow::Context,
textures: Vec<TextureData>, textures: Vec<TextureResource>,
) -> Result<FastHashMap<usize, InputTexture>> { ) -> Result<FastHashMap<usize, InputTexture>> {
let mut luts = FastHashMap::default(); let mut luts = FastHashMap::default();

View file

@ -60,7 +60,7 @@ static FINAL_VBO_DATA: &[VertexInput; 4] = &[
pub(crate) trait LoadLut { pub(crate) trait LoadLut {
fn load_luts( fn load_luts(
context: &glow::Context, context: &glow::Context,
textures: Vec<TextureData>, textures: Vec<TextureResource>,
) -> Result<FastHashMap<usize, InputTexture>>; ) -> Result<FastHashMap<usize, InputTexture>>;
} }
@ -172,4 +172,4 @@ pub(crate) trait GLInterface {
} }
pub(crate) use framebuffer::OutputFramebuffer; pub(crate) use framebuffer::OutputFramebuffer;
use librashader_pack::TextureData; use librashader_pack::TextureResource;

View file

@ -41,7 +41,7 @@ use std::path::Path;
mod compile { mod compile {
use super::*; use super::*;
use librashader_pack::{ShaderPassData, TextureData}; use librashader_pack::{PassResource, TextureResource};
#[cfg(not(feature = "stable"))] #[cfg(not(feature = "stable"))]
pub type ShaderPassMeta = pub type ShaderPassMeta =
@ -52,8 +52,8 @@ mod compile {
ShaderPassArtifact<Box<dyn CompileReflectShader<MSL, SpirvCompilation, SpirvCross> + Send>>; ShaderPassArtifact<Box<dyn CompileReflectShader<MSL, SpirvCompilation, SpirvCross> + Send>>;
pub fn compile_passes( pub fn compile_passes(
shaders: Vec<ShaderPassData>, shaders: Vec<PassResource>,
textures: &[TextureData], textures: &[TextureResource],
) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> { ) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> {
let (passes, semantics) = MSL::compile_preset_passes::< let (passes, semantics) = MSL::compile_preset_passes::<
SpirvCompilation, SpirvCompilation,
@ -65,7 +65,7 @@ mod compile {
} }
use compile::{compile_passes, ShaderPassMeta}; use compile::{compile_passes, ShaderPassMeta};
use librashader_pack::{ShaderPresetPack, TextureData}; use librashader_pack::{ShaderPresetPack, TextureResource};
use librashader_runtime::parameters::RuntimeParameters; use librashader_runtime::parameters::RuntimeParameters;
/// A Metal filter chain. /// A Metal filter chain.
@ -149,7 +149,7 @@ impl FilterChainMetal {
fn load_luts( fn load_luts(
device: &ProtocolObject<dyn MTLDevice>, device: &ProtocolObject<dyn MTLDevice>,
cmd: &ProtocolObject<dyn MTLCommandBuffer>, cmd: &ProtocolObject<dyn MTLCommandBuffer>,
textures: Vec<TextureData>, textures: Vec<TextureResource>,
) -> error::Result<FastHashMap<usize, LutTexture>> { ) -> error::Result<FastHashMap<usize, LutTexture>> {
let mut luts = FastHashMap::default(); let mut luts = FastHashMap::default();
@ -315,7 +315,7 @@ impl FilterChainMetal {
cmd: &ProtocolObject<dyn MTLCommandBuffer>, cmd: &ProtocolObject<dyn MTLCommandBuffer>,
options: Option<&FilterChainOptionsMetal>, options: Option<&FilterChainOptionsMetal>,
) -> error::Result<FilterChainMetal> { ) -> error::Result<FilterChainMetal> {
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)?; let filters = Self::init_passes(&device, passes, &semantics)?;
@ -352,7 +352,7 @@ impl FilterChainMetal {
common: FilterCommon { common: FilterCommon {
luts, luts,
samplers, samplers,
config: RuntimeParameters::new(preset.shader_count as usize, preset.parameters), config: RuntimeParameters::new(preset.pass_count as usize, preset.parameters),
draw_quad, draw_quad,
device, device,
output_textures, output_textures,

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::ShaderPassMeta; use librashader_presets::PassMeta;
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 meta: ShaderPassMeta, pub meta: PassMeta,
pub graphics_pipeline: MetalGraphicsPipeline, pub graphics_pipeline: MetalGraphicsPipeline,
} }
@ -177,7 +177,7 @@ impl FilterPassMeta for FilterPass {
self.source.format self.source.format
} }
fn meta(&self) -> &ShaderPassMeta { fn meta(&self) -> &PassMeta {
&self.meta &self.meta
} }
} }

View file

@ -250,7 +250,7 @@ impl Drop for FrameResiduals {
mod compile { mod compile {
use super::*; use super::*;
use librashader_pack::ShaderPassData; use librashader_pack::PassResource;
#[cfg(not(feature = "stable"))] #[cfg(not(feature = "stable"))]
pub type ShaderPassMeta = pub type ShaderPassMeta =
@ -262,8 +262,8 @@ mod compile {
>; >;
pub fn compile_passes( pub fn compile_passes(
shaders: Vec<ShaderPassData>, shaders: Vec<PassResource>,
textures: &[TextureData], textures: &[TextureResource],
disable_cache: bool, disable_cache: bool,
) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> { ) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> {
let (passes, semantics) = if !disable_cache { let (passes, semantics) = if !disable_cache {
@ -284,7 +284,7 @@ mod compile {
} }
use compile::{compile_passes, ShaderPassMeta}; use compile::{compile_passes, ShaderPassMeta};
use librashader_pack::{ShaderPresetPack, TextureData}; use librashader_pack::{ShaderPresetPack, TextureResource};
use librashader_runtime::parameters::RuntimeParameters; use librashader_runtime::parameters::RuntimeParameters;
impl FilterChainVulkan { impl FilterChainVulkan {
@ -415,7 +415,7 @@ impl FilterChainVulkan {
FilterChainError: From<E>, FilterChainError: From<E>,
{ {
let disable_cache = options.map_or(false, |o| o.disable_cache); 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)?; let device = vulkan.try_into().map_err(From::from)?;
@ -466,7 +466,7 @@ impl FilterChainVulkan {
common: FilterCommon { common: FilterCommon {
luts, luts,
samplers, 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)?, draw_quad: DrawQuad::new(&device.device, &device.alloc)?,
device: device.device.clone(), device: device.device.clone(),
output_textures, output_textures,
@ -559,7 +559,7 @@ impl FilterChainVulkan {
fn load_luts( fn load_luts(
vulkan: &VulkanObjects, vulkan: &VulkanObjects,
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
textures: Vec<TextureData>, textures: Vec<TextureResource>,
) -> error::Result<FastHashMap<usize, LutTexture>> { ) -> error::Result<FastHashMap<usize, LutTexture>> {
let mut luts = FastHashMap::default(); let mut luts = FastHashMap::default();
let textures = textures let textures = textures

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::ShaderPassMeta; use librashader_presets::PassMeta;
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 meta: ShaderPassMeta, pub meta: PassMeta,
pub graphics_pipeline: VulkanGraphicsPipeline, pub graphics_pipeline: VulkanGraphicsPipeline,
pub frames_in_flight: u32, pub frames_in_flight: u32,
} }
@ -78,7 +78,7 @@ impl FilterPassMeta for FilterPass {
self.source.format self.source.format
} }
fn meta(&self) -> &ShaderPassMeta { fn meta(&self) -> &PassMeta {
&self.meta &self.meta
} }
} }

View file

@ -40,7 +40,7 @@ use crate::texture::{InputImage, OwnedImage};
mod compile { mod compile {
use super::*; use super::*;
use librashader_pack::{ShaderPassData, TextureData}; use librashader_pack::{PassResource, TextureResource};
#[cfg(not(feature = "stable"))] #[cfg(not(feature = "stable"))]
pub type ShaderPassMeta = pub type ShaderPassMeta =
@ -51,8 +51,8 @@ mod compile {
ShaderPassArtifact<Box<dyn CompileReflectShader<WGSL, SpirvCompilation, Naga> + Send>>; ShaderPassArtifact<Box<dyn CompileReflectShader<WGSL, SpirvCompilation, Naga> + Send>>;
pub fn compile_passes( pub fn compile_passes(
shaders: Vec<ShaderPassData>, shaders: Vec<PassResource>,
textures: &[TextureData], textures: &[TextureResource],
) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> { ) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> {
let (passes, semantics) = WGSL::compile_preset_passes::< let (passes, semantics) = WGSL::compile_preset_passes::<
SpirvCompilation, SpirvCompilation,
@ -64,7 +64,7 @@ mod compile {
} }
use compile::{compile_passes, ShaderPassMeta}; use compile::{compile_passes, ShaderPassMeta};
use librashader_pack::{ShaderPresetPack, TextureData}; use librashader_pack::{ShaderPresetPack, TextureResource};
use librashader_runtime::parameters::RuntimeParameters; use librashader_runtime::parameters::RuntimeParameters;
/// A wgpu filter chain. /// A wgpu filter chain.
@ -176,7 +176,7 @@ impl FilterChainWgpu {
cmd: &mut wgpu::CommandEncoder, cmd: &mut wgpu::CommandEncoder,
options: Option<&FilterChainOptionsWgpu>, options: Option<&FilterChainOptionsWgpu>,
) -> error::Result<FilterChainWgpu> { ) -> error::Result<FilterChainWgpu> {
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. // cache is opt-in for wgpu, not opt-out because of feature requirements.
let disable_cache = options.map_or(true, |o| !o.enable_cache); let disable_cache = options.map_or(true, |o| !o.enable_cache);
@ -234,7 +234,7 @@ impl FilterChainWgpu {
common: FilterCommon { common: FilterCommon {
luts, luts,
samplers, samplers,
config: RuntimeParameters::new(preset.shader_count as usize, preset.parameters), config: RuntimeParameters::new(preset.pass_count as usize, preset.parameters),
draw_quad, draw_quad,
device, device,
queue, queue,
@ -258,7 +258,7 @@ impl FilterChainWgpu {
cmd: &mut wgpu::CommandEncoder, cmd: &mut wgpu::CommandEncoder,
mipmapper: &mut MipmapGen, mipmapper: &mut MipmapGen,
sampler_set: &SamplerSet, sampler_set: &SamplerSet,
textures: Vec<TextureData>, textures: Vec<TextureResource>,
) -> error::Result<FastHashMap<usize, LutTexture>> { ) -> error::Result<FastHashMap<usize, LutTexture>> {
let mut luts = FastHashMap::default(); let mut luts = FastHashMap::default();

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::ShaderPassMeta; use librashader_presets::PassMeta;
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 meta: ShaderPassMeta, pub meta: PassMeta,
pub graphics_pipeline: WgpuGraphicsPipeline, pub graphics_pipeline: WgpuGraphicsPipeline,
} }
@ -255,7 +255,7 @@ impl FilterPassMeta for FilterPass {
self.source.format self.source.format
} }
fn meta(&self) -> &ShaderPassMeta { fn meta(&self) -> &PassMeta {
&self.meta &self.meta
} }
} }

View file

@ -1,5 +1,5 @@
use librashader_common::ImageFormat; use librashader_common::ImageFormat;
use librashader_presets::ShaderPassMeta; use librashader_presets::PassMeta;
/// Trait for metadata about a filter pass. /// Trait for metadata about a filter pass.
pub trait FilterPassMeta { pub trait FilterPassMeta {
@ -7,7 +7,7 @@ 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 meta(&self) -> &ShaderPassMeta; fn meta(&self) -> &PassMeta;
/// Gets the format of the filter pass framebuffer. /// Gets the format of the filter pass framebuffer.
#[inline(always)] #[inline(always)]

View file

@ -4,7 +4,7 @@ use std::marker::PhantomData;
use image::error::{LimitError, LimitErrorKind}; use image::error::{LimitError, LimitErrorKind};
use image::DynamicImage; use image::DynamicImage;
use librashader_pack::{TextureBuffer, TextureData}; use librashader_pack::{TextureBuffer, TextureResource};
use librashader_presets::TextureMeta; use librashader_presets::TextureMeta;
use std::path::Path; use std::path::Path;
@ -117,7 +117,7 @@ impl<P: PixelFormat> Image<P> {
} }
} }
/// 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<P: PixelFormat = RGBA8> { pub struct LoadedTexture<P: PixelFormat = RGBA8> {
/// The loaded image data /// The loaded image data
pub image: Image<P>, pub image: Image<P>,
@ -127,7 +127,10 @@ pub struct LoadedTexture<P: PixelFormat = RGBA8> {
impl<P: PixelFormat> LoadedTexture<P> { impl<P: PixelFormat> LoadedTexture<P> {
/// Load the texture with the given UV direction and subpixel ordering. /// Load the texture with the given UV direction and subpixel ordering.
pub fn from_texture(texture: TextureData, direction: UVDirection) -> Result<Self, ImageError> { pub fn from_texture(
texture: TextureResource,
direction: UVDirection,
) -> Result<Self, ImageError> {
Ok(LoadedTexture { Ok(LoadedTexture {
meta: texture.meta, meta: texture.meta,
image: Image::load_from_buffer(texture.data, direction)?, image: Image::load_from_buffer(texture.data, direction)?,

View file

@ -77,7 +77,7 @@ pub mod presets {
preset: &ShaderPreset, preset: &ShaderPreset,
) -> Result<impl Iterator<Item = ShaderParameter>, PreprocessError> { ) -> Result<impl Iterator<Item = ShaderParameter>, PreprocessError> {
let iters: Result<Vec<Vec<ShaderParameter>>, PreprocessError> = preset let iters: Result<Vec<Vec<ShaderParameter>>, PreprocessError> = preset
.shaders .passes
.iter() .iter()
.map(|s| { .map(|s| {
ShaderSource::load(&s.path) ShaderSource::load(&s.path)
@ -131,7 +131,7 @@ pub mod preprocess {
/// pub fn compile_preset(preset: ShaderPreset) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), Box<dyn Error>> /// pub fn compile_preset(preset: ShaderPreset) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), Box<dyn Error>>
/// { /// {
/// let (passes, semantics) = SPIRV::compile_preset_passes::<SpirvCompilation, SpirvCross, Box<dyn Error>>( /// let (passes, semantics) = SPIRV::compile_preset_passes::<SpirvCompilation, SpirvCross, Box<dyn Error>>(
/// preset.shaders, &preset.textures)?; /// preset.passes, &preset.textures)?;
/// Ok((passes, semantics)) /// Ok((passes, semantics))
/// } /// }
/// } /// }

View file

@ -14,9 +14,9 @@ use librashader::reflect::FromCompilation;
use librashader::reflect::OutputTarget; use librashader::reflect::OutputTarget;
use librashader::reflect::SpirvCompilation; use librashader::reflect::SpirvCompilation;
use librashader_pack::{LoadableResource, ShaderPassData}; use librashader_pack::{LoadableResource, PassResource};
use librashader_preprocess::PreprocessError; use librashader_preprocess::PreprocessError;
use librashader_presets::ShaderPassMeta; use librashader_presets::PassMeta;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
static ALL_SLANG_PRESETS: Lazy<RwLock<Vec<(PathBuf, ShaderPreset)>>> = static ALL_SLANG_PRESETS: Lazy<RwLock<Vec<(PathBuf, ShaderPreset)>>> =
@ -57,7 +57,7 @@ fn collect_all_loadable_slang_presets() -> Vec<(PathBuf, ShaderPreset)> {
let mut presets = collect_all_slang_presets(false); let mut presets = collect_all_slang_presets(false);
presets.retain(|(_, preset)| { presets.retain(|(_, preset)| {
!preset !preset
.shaders .passes
.par_iter() .par_iter()
.any(|shader| ShaderSource::load(&shader.path).is_err()) .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); let presets = collect_all_slang_presets(true);
for (path, preset) in presets { 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) { if let Err(e) = ShaderSource::load(&shader.path) {
#[cfg(not(feature = "github-ci"))] #[cfg(not(feature = "github-ci"))]
eprintln!( eprintln!(
@ -143,11 +143,11 @@ where
); );
let shader_pass_data = preset let shader_pass_data = preset
.shaders .passes
.par_iter() .par_iter()
.map(|p| { .map(|p| {
( (
ShaderPassMeta::load(&p.path).map(|data| ShaderPassData { PassMeta::load(&p.path).map(|data| PassResource {
meta: p.meta.clone(), meta: p.meta.clone(),
data, data,
}), }),
@ -169,7 +169,7 @@ where
}; };
e e
}) })
.collect::<Result<Vec<ShaderPassData>, PreprocessError>>(); .collect::<Result<Vec<PassResource>, PreprocessError>>();
let Ok(shader_pass_data) = shader_pass_data else { let Ok(shader_pass_data) = shader_pass_data else {
return; return;