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 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<Vec<u32>>,
}
pub(crate) struct FilterReflection {
@ -35,7 +35,7 @@ impl FilterReflection {
preset: ShaderPreset,
direction: UVDirection,
) -> 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::<
Glslang,

View file

@ -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"));
};

View file

@ -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<RgbaImage> 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<M: LoadableResource> {
pub struct LoadedResource<M: LoadableResource> {
/// 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<Self::ResourceType, Self::Error>;
}
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<ShaderPassMeta>;
pub type TextureData = ShaderPresetResource<TextureMeta>;
/// The loaded resource information for the source code of a shader pass.
pub type PassResource = LoadedResource<PassMeta>;
/// 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.
#[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<ShaderPassData>,
pub passes: Vec<PassResource>,
/// Preset information for each texture.
pub textures: Vec<TextureData>,
pub textures: Vec<TextureResource>,
/// Preset information for each user parameter.
pub parameters: Vec<ParameterMeta>,
@ -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,
})

View file

@ -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<Value>) -> 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<Value>) -> ShaderPreset {
ShaderPreset {
#[cfg(feature = "parse_legacy_glsl")]
feedback_pass,
shader_count,
shaders,
pass_count: shader_count,
passes: shaders,
textures,
parameters,
}

View file

@ -6,7 +6,7 @@ use std::path::PathBuf;
use std::str::FromStr;
/// 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.
pub type TextureConfig = PathReference<TextureMeta>;
@ -24,7 +24,7 @@ pub struct PathReference<M> {
/// 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<ShaderPassConfig>,
pub passes: Vec<PassConfig>,
/// Preset information for each texture.
pub textures: Vec<TextureConfig>,

View file

@ -34,7 +34,7 @@
//! 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>>(
//! preset.shaders, &preset.textures)?;
//! preset.passes, &preset.textures)?;
//! Ok((passes, semantics))
//! }
//! ```

View file

@ -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<T> = (ShaderPassMeta, ShaderSource, CompilerBackend<T>);
pub type ShaderPassArtifact<T> = (PassMeta, ShaderSource, CompilerBackend<T>);
impl<T: OutputTarget> 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<ShaderPassData>,
passes: Vec<PassResource>,
textures: impl Iterator<Item = &'a TextureMeta>,
) -> 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<ShaderPassData>,
passes: Vec<PassResource>,
textures: impl Iterator<Item = &'a TextureMeta>,
) -> Result<
(
@ -103,7 +103,7 @@ where
}
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 {
insert_pass_semantics(
@ -232,7 +232,7 @@ impl ShaderSemantics {
Default::default();
let config = preset
.shaders
.passes
.get(index)
.ok_or_else(|| PreprocessError::InvalidStage)?;

View file

@ -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<ShaderPassData>,
textures: &[TextureData],
shaders: Vec<PassResource>,
textures: &[TextureResource],
disable_cache: bool,
) -> Result<(Vec<ShaderPassMeta>, 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<FilterChainD3D11> {
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<TextureData>,
textures: Vec<TextureResource>,
) -> error::Result<FastHashMap<usize, LutTexture>> {
let mut luts = FastHashMap::default();
let textures = textures

View file

@ -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<ConstantBufferBinding>,
pub push_buffer: Option<ConstantBufferBinding>,
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
}
}

View file

@ -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<ShaderPassData>,
textures: &[TextureData],
shaders: Vec<PassResource>,
textures: &[TextureResource],
disable_cache: bool,
) -> Result<(Vec<DxilShaderPassMeta>, ShaderSemantics), FilterChainError> {
let (passes, semantics) = if !disable_cache {
@ -217,8 +217,8 @@ mod compile {
>;
pub fn compile_passes_hlsl(
shaders: Vec<ShaderPassData>,
textures: &[TextureData],
shaders: Vec<PassResource>,
textures: &[TextureResource],
disable_cache: bool,
) -> Result<(Vec<HlslShaderPassMeta>, 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<FilterChainD3D12> {
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<CpuStagingHeap>,
mipmap_heap: &mut D3D12DescriptorHeap<ResourceWorkHeap>,
gc: &mut FrameResiduals,
textures: Vec<TextureData>,
textures: Vec<TextureResource>,
) -> error::Result<FastHashMap<usize, LutTexture>> {
// use separate mipgen to load luts.
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::{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<UniformBinding, MemberOffset>,
pub uniform_storage:
UniformStorage<NoUniformBinder, Option<()>, RawD3D12Buffer, RawD3D12Buffer>,
@ -77,7 +77,7 @@ impl FilterPassMeta for FilterPass {
self.source.format
}
fn meta(&self) -> &ShaderPassMeta {
fn meta(&self) -> &PassMeta {
&self.meta
}
}

View file

@ -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<ShaderPassData>,
textures: &[TextureData],
shaders: Vec<PassResource>,
textures: &[TextureResource],
disable_cache: bool,
) -> Result<(Vec<ShaderPassMeta>, 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<TextureData>,
textures: Vec<TextureResource>,
) -> error::Result<FastHashMap<usize, LutTexture>> {
let mut luts = FastHashMap::default();
let images = textures
@ -236,7 +236,7 @@ impl FilterChainD3D9 {
) -> error::Result<FilterChainD3D9> {
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,

View file

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

View file

@ -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<ShaderPassData>,
textures: &[TextureData],
shaders: Vec<PassResource>,
textures: &[TextureResource],
disable_cache: bool,
) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> {
let (passes, semantics) = if !disable_cache {
@ -140,7 +140,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
options: Option<&FilterChainOptionsGL>,
) -> error::Result<Self> {
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<T: GLInterface> FilterChainImpl<T> {
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,

View file

@ -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<T: GLInterface> {
pub(crate) uniform_storage: GlUniformStorage,
pub uniform_bindings: FastHashMap<UniformBinding, UniformOffset>,
pub source: ShaderSource,
pub meta: ShaderPassMeta,
pub meta: PassMeta,
}
impl TextureInput for InputTexture {
@ -162,7 +162,7 @@ impl<T: GLInterface> FilterPassMeta for FilterPass<T> {
self.source.format
}
fn meta(&self) -> &ShaderPassMeta {
fn meta(&self) -> &PassMeta {
&self.meta
}
}

View file

@ -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<TextureData>,
textures: Vec<TextureResource>,
) -> Result<FastHashMap<usize, InputTexture>> {
let mut luts = FastHashMap::default();
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 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<TextureData>,
textures: Vec<TextureResource>,
) -> Result<FastHashMap<usize, InputTexture>> {
let mut luts = FastHashMap::default();

View file

@ -60,7 +60,7 @@ static FINAL_VBO_DATA: &[VertexInput; 4] = &[
pub(crate) trait LoadLut {
fn load_luts(
context: &glow::Context,
textures: Vec<TextureData>,
textures: Vec<TextureResource>,
) -> Result<FastHashMap<usize, InputTexture>>;
}
@ -172,4 +172,4 @@ pub(crate) trait GLInterface {
}
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 {
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<Box<dyn CompileReflectShader<MSL, SpirvCompilation, SpirvCross> + Send>>;
pub fn compile_passes(
shaders: Vec<ShaderPassData>,
textures: &[TextureData],
shaders: Vec<PassResource>,
textures: &[TextureResource],
) -> Result<(Vec<ShaderPassMeta>, 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<dyn MTLDevice>,
cmd: &ProtocolObject<dyn MTLCommandBuffer>,
textures: Vec<TextureData>,
textures: Vec<TextureResource>,
) -> error::Result<FastHashMap<usize, LutTexture>> {
let mut luts = FastHashMap::default();
@ -315,7 +315,7 @@ impl FilterChainMetal {
cmd: &ProtocolObject<dyn MTLCommandBuffer>,
options: Option<&FilterChainOptionsMetal>,
) -> 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)?;
@ -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,

View file

@ -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<NoUniformBinder, Option<()>, MetalBuffer, MetalBuffer>,
pub uniform_bindings: FastHashMap<UniformBinding, MemberOffset>,
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
}
}

View file

@ -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<ShaderPassData>,
textures: &[TextureData],
shaders: Vec<PassResource>,
textures: &[TextureResource],
disable_cache: bool,
) -> Result<(Vec<ShaderPassMeta>, 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<E>,
{
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<TextureData>,
textures: Vec<TextureResource>,
) -> error::Result<FastHashMap<usize, LutTexture>> {
let mut luts = FastHashMap::default();
let textures = textures

View file

@ -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<NoUniformBinder, Option<()>, RawVulkanBuffer, Box<[u8]>, Arc<ash::Device>>,
pub uniform_bindings: FastHashMap<UniformBinding, MemberOffset>,
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
}
}

View file

@ -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<Box<dyn CompileReflectShader<WGSL, SpirvCompilation, Naga> + Send>>;
pub fn compile_passes(
shaders: Vec<ShaderPassData>,
textures: &[TextureData],
shaders: Vec<PassResource>,
textures: &[TextureResource],
) -> Result<(Vec<ShaderPassMeta>, 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<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.
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<TextureData>,
textures: Vec<TextureResource>,
) -> error::Result<FastHashMap<usize, LutTexture>> {
let mut luts = FastHashMap::default();

View file

@ -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<UniformBinding, MemberOffset>,
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
}
}

View file

@ -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)]

View file

@ -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<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> {
/// The loaded image data
pub image: Image<P>,
@ -127,7 +127,10 @@ pub struct LoadedTexture<P: PixelFormat = RGBA8> {
impl<P: PixelFormat> LoadedTexture<P> {
/// 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 {
meta: texture.meta,
image: Image::load_from_buffer(texture.data, direction)?,

View file

@ -77,7 +77,7 @@ pub mod presets {
preset: &ShaderPreset,
) -> Result<impl Iterator<Item = ShaderParameter>, PreprocessError> {
let iters: Result<Vec<Vec<ShaderParameter>>, 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<ShaderPassMeta>, ShaderSemantics), 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))
/// }
/// }

View file

@ -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<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);
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::<Result<Vec<ShaderPassData>, PreprocessError>>();
.collect::<Result<Vec<PassResource>, PreprocessError>>();
let Ok(shader_pass_data) = shader_pass_data else {
return;