Compare commits
7 commits
30bb747e94
...
e45e5f242d
Author | SHA1 | Date | |
---|---|---|---|
Alex Janka | e45e5f242d | ||
fff80df5a0 | |||
875968d097 | |||
fa48b936be | |||
0a9fa16855 | |||
d558c6e50d | |||
48d91dfe58 |
1021
Cargo.lock
generated
1021
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -181,7 +181,6 @@ pub(crate) use config_struct;
|
|||
pub(crate) use config_version_set;
|
||||
|
||||
#[doc(hidden)]
|
||||
#[deny(deprecated)]
|
||||
#[deprecated = "Forward declarations for cbindgen, do not use."]
|
||||
mod __cbindgen_opaque_forward_declarations {
|
||||
macro_rules! typedef_struct {
|
||||
|
@ -189,7 +188,6 @@ mod __cbindgen_opaque_forward_declarations {
|
|||
$($(#[$($attrss)*])*
|
||||
#[allow(unused)]
|
||||
#[doc(hidden)]
|
||||
#[deny(deprecated)]
|
||||
#[deprecated]
|
||||
pub struct $name;
|
||||
)*
|
||||
|
|
|
@ -66,7 +66,6 @@
|
|||
#![allow(non_camel_case_types)]
|
||||
#![feature(try_blocks)]
|
||||
#![deny(unsafe_op_in_unsafe_fn)]
|
||||
#![deny(deprecated)]
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
|
|
|
@ -42,6 +42,12 @@ use num_traits::AsPrimitive;
|
|||
use std::convert::Infallible;
|
||||
use std::str::FromStr;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum ShaderStorage {
|
||||
Path(std::path::PathBuf),
|
||||
String(String),
|
||||
}
|
||||
|
||||
#[repr(u32)]
|
||||
#[derive(Default, Copy, Clone, Debug, Eq, PartialEq, Hash)]
|
||||
/// Supported image formats for textures.
|
||||
|
|
|
@ -17,7 +17,6 @@ use crate::include::read_source;
|
|||
pub use error::*;
|
||||
use librashader_common::map::FastHashMap;
|
||||
use librashader_common::ImageFormat;
|
||||
use std::path::Path;
|
||||
|
||||
/// The source file for a single shader pass.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
|
@ -58,8 +57,8 @@ pub struct ShaderParameter {
|
|||
impl ShaderSource {
|
||||
/// Load the source file at the given path, resolving includes relative to the location of the
|
||||
/// source file.
|
||||
pub fn load(path: impl AsRef<Path>) -> Result<ShaderSource, PreprocessError> {
|
||||
load_shader_source(path)
|
||||
pub fn load(file: &librashader_common::ShaderStorage) -> Result<ShaderSource, PreprocessError> {
|
||||
load_shader_source(file)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,8 +77,14 @@ impl SourceOutput for String {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn load_shader_source(path: impl AsRef<Path>) -> Result<ShaderSource, PreprocessError> {
|
||||
let source = read_source(path)?;
|
||||
pub(crate) fn load_shader_source(
|
||||
file: &librashader_common::ShaderStorage,
|
||||
) -> Result<ShaderSource, PreprocessError> {
|
||||
let source = match file {
|
||||
librashader_common::ShaderStorage::Path(path) => read_source(path)?,
|
||||
librashader_common::ShaderStorage::String(s) => s.to_string(),
|
||||
};
|
||||
|
||||
let meta = pragma::parse_pragma_meta(&source)?;
|
||||
let text = stage::process_stages(&source)?;
|
||||
let parameters = FastHashMap::from_iter(meta.parameters.into_iter().map(|p| (p.id.clone(), p)));
|
||||
|
|
|
@ -115,7 +115,7 @@ pub fn resolve_values(mut values: Vec<Value>) -> ShaderPreset {
|
|||
|
||||
let shader = ShaderPassConfig {
|
||||
id,
|
||||
name,
|
||||
name: librashader_common::ShaderStorage::Path(name),
|
||||
alias: shader_values.iter().find_map(|f| match f {
|
||||
Value::Alias(_, value) => Some(value.to_string()),
|
||||
_ => None,
|
||||
|
|
|
@ -10,7 +10,7 @@ pub struct ShaderPassConfig {
|
|||
/// The index of the shader pass relative to its parent preset.
|
||||
pub id: i32,
|
||||
/// The fully qualified path to the shader pass source file.
|
||||
pub name: PathBuf,
|
||||
pub name: librashader_common::ShaderStorage,
|
||||
/// The alias of the shader pass if available.
|
||||
pub alias: Option<String>,
|
||||
/// The filtering mode that this shader pass should expect.
|
||||
|
|
|
@ -75,9 +75,12 @@ pub(crate) struct FilterCommon {
|
|||
pub(crate) draw_quad: DrawQuad,
|
||||
}
|
||||
|
||||
type ShaderPassMeta =
|
||||
mod compile {
|
||||
use super::*;
|
||||
pub type ShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<HLSL, SpirvCompilation, SpirvCross> + Send>;
|
||||
fn compile_passes(
|
||||
|
||||
pub fn compile_passes(
|
||||
shaders: Vec<ShaderPassConfig>,
|
||||
textures: &[TextureConfig],
|
||||
disable_cache: bool,
|
||||
|
@ -96,6 +99,9 @@ fn compile_passes(
|
|||
|
||||
Ok((passes, semantics))
|
||||
}
|
||||
}
|
||||
|
||||
use compile::{compile_passes, ShaderPassMeta};
|
||||
|
||||
impl FilterChainD3D11 {
|
||||
/// Load the shader preset at the given path into a filter chain.
|
||||
|
|
|
@ -146,9 +146,12 @@ impl Drop for FrameResiduals {
|
|||
}
|
||||
}
|
||||
|
||||
type DxilShaderPassMeta =
|
||||
mod compile {
|
||||
use super::*;
|
||||
pub type DxilShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<DXIL, SpirvCompilation, SpirvCross> + Send>;
|
||||
fn compile_passes_dxil(
|
||||
|
||||
pub fn compile_passes_dxil(
|
||||
shaders: Vec<ShaderPassConfig>,
|
||||
textures: &[TextureConfig],
|
||||
disable_cache: bool,
|
||||
|
@ -167,9 +170,11 @@ fn compile_passes_dxil(
|
|||
|
||||
Ok((passes, semantics))
|
||||
}
|
||||
type HlslShaderPassMeta =
|
||||
|
||||
pub type HlslShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<HLSL, SpirvCompilation, SpirvCross> + Send>;
|
||||
fn compile_passes_hlsl(
|
||||
|
||||
pub fn compile_passes_hlsl(
|
||||
shaders: Vec<ShaderPassConfig>,
|
||||
textures: &[TextureConfig],
|
||||
disable_cache: bool,
|
||||
|
@ -188,6 +193,9 @@ fn compile_passes_hlsl(
|
|||
|
||||
Ok((passes, semantics))
|
||||
}
|
||||
}
|
||||
|
||||
use compile::{compile_passes_dxil, compile_passes_hlsl, DxilShaderPassMeta, HlslShaderPassMeta};
|
||||
|
||||
impl FilterChainD3D12 {
|
||||
/// Load the shader preset at the given path into a filter chain.
|
||||
|
|
|
@ -63,10 +63,12 @@ pub struct FilterChainD3D9 {
|
|||
default_options: FrameOptionsD3D9,
|
||||
}
|
||||
|
||||
type ShaderPassMeta =
|
||||
mod compile {
|
||||
use super::*;
|
||||
pub type ShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<HLSL, SpirvCompilation, SpirvCross> + Send>;
|
||||
|
||||
fn compile_passes(
|
||||
pub fn compile_passes(
|
||||
shaders: Vec<ShaderPassConfig>,
|
||||
textures: &[TextureConfig],
|
||||
disable_cache: bool,
|
||||
|
@ -85,6 +87,9 @@ fn compile_passes(
|
|||
|
||||
Ok((passes, semantics))
|
||||
}
|
||||
}
|
||||
|
||||
use compile::{compile_passes, ShaderPassMeta};
|
||||
|
||||
impl FilterChainD3D9 {
|
||||
fn init_passes(
|
||||
|
|
|
@ -92,9 +92,12 @@ impl<T: GLInterface> FilterChainImpl<T> {
|
|||
}
|
||||
}
|
||||
|
||||
type ShaderPassMeta =
|
||||
mod compile {
|
||||
use super::*;
|
||||
pub type ShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<GLSL, SpirvCompilation, SpirvCross>>;
|
||||
fn compile_passes(
|
||||
|
||||
pub fn compile_passes(
|
||||
shaders: Vec<ShaderPassConfig>,
|
||||
textures: &[TextureConfig],
|
||||
disable_cache: bool,
|
||||
|
@ -113,6 +116,9 @@ fn compile_passes(
|
|||
|
||||
Ok((passes, semantics))
|
||||
}
|
||||
}
|
||||
|
||||
use compile::{compile_passes, ShaderPassMeta};
|
||||
|
||||
impl<T: GLInterface> FilterChainImpl<T> {
|
||||
/// Load a filter chain from a pre-parsed `ShaderPreset`.
|
||||
|
|
|
@ -40,9 +40,12 @@ use std::collections::VecDeque;
|
|||
use std::fmt::{Debug, Formatter};
|
||||
use std::path::Path;
|
||||
|
||||
type ShaderPassMeta =
|
||||
mod compile {
|
||||
use super::*;
|
||||
pub type ShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<MSL, SpirvCompilation, SpirvCross> + Send>;
|
||||
fn compile_passes(
|
||||
|
||||
pub fn compile_passes(
|
||||
shaders: Vec<ShaderPassConfig>,
|
||||
textures: &[TextureConfig],
|
||||
) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> {
|
||||
|
@ -52,6 +55,9 @@ fn compile_passes(
|
|||
)?;
|
||||
Ok((passes, semantics))
|
||||
}
|
||||
}
|
||||
|
||||
use compile::{compile_passes, ShaderPassMeta};
|
||||
|
||||
/// A Metal filter chain.
|
||||
pub struct FilterChainMetal {
|
||||
|
|
|
@ -209,9 +209,12 @@ impl Drop for FrameResiduals {
|
|||
}
|
||||
}
|
||||
|
||||
type ShaderPassMeta =
|
||||
mod compile {
|
||||
use super::*;
|
||||
pub type ShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<SPIRV, SpirvCompilation, SpirvCross> + Send>;
|
||||
fn compile_passes(
|
||||
|
||||
pub fn compile_passes(
|
||||
shaders: Vec<ShaderPassConfig>,
|
||||
textures: &[TextureConfig],
|
||||
disable_cache: bool,
|
||||
|
@ -230,6 +233,9 @@ fn compile_passes(
|
|||
|
||||
Ok((passes, semantics))
|
||||
}
|
||||
}
|
||||
|
||||
use compile::{compile_passes, ShaderPassMeta};
|
||||
|
||||
impl FilterChainVulkan {
|
||||
/// Load the shader preset at the given path into a filter chain.
|
||||
|
|
|
@ -21,7 +21,7 @@ librashader-reflect = { path = "../librashader-reflect", version = "0.2.7", feat
|
|||
librashader-runtime = { path = "../librashader-runtime" , version = "0.2.7" }
|
||||
|
||||
wgpu = { version = "0.20.0", default-features = false, features = ["wgsl"] }
|
||||
image = "0.24.7"
|
||||
image = "0.25.1"
|
||||
thiserror = "1.0.50"
|
||||
bytemuck = { version = "1.14.0", features = ["derive"] }
|
||||
array-concat = "0.5.2"
|
||||
|
|
|
@ -38,9 +38,12 @@ use crate::options::{FilterChainOptionsWgpu, FrameOptionsWgpu};
|
|||
use crate::samplers::SamplerSet;
|
||||
use crate::texture::{InputImage, OwnedImage};
|
||||
|
||||
type ShaderPassMeta =
|
||||
mod compile {
|
||||
use super::*;
|
||||
pub type ShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<WGSL, SpirvCompilation, Naga> + Send>;
|
||||
fn compile_passes(
|
||||
|
||||
pub fn compile_passes(
|
||||
shaders: Vec<ShaderPassConfig>,
|
||||
textures: &[TextureConfig],
|
||||
) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> {
|
||||
|
@ -50,6 +53,9 @@ fn compile_passes(
|
|||
)?;
|
||||
Ok((passes, semantics))
|
||||
}
|
||||
}
|
||||
|
||||
use compile::{compile_passes, ShaderPassMeta};
|
||||
|
||||
/// A wgpu filter chain.
|
||||
pub struct FilterChainWgpu {
|
||||
|
|
|
@ -23,7 +23,7 @@ array-concat = "0.5.2"
|
|||
tinymap = "0.4.0"
|
||||
|
||||
[dependencies.image]
|
||||
version = "0.24.5"
|
||||
version = "0.25.1"
|
||||
features = [
|
||||
"gif", "jpeg", "png",
|
||||
"tga", "pnm", "tiff",
|
||||
|
|
|
@ -5,24 +5,27 @@ use librashader_presets::{Scale2D, ScaleFactor, ScaleType, Scaling};
|
|||
use num_traits::AsPrimitive;
|
||||
use std::ops::Mul;
|
||||
|
||||
pub const MAX_TEXEL_SIZE: f32 = 16384f32;
|
||||
|
||||
/// Trait for size scaling relative to the viewport.
|
||||
pub trait ViewportSize<T>
|
||||
where
|
||||
T: Mul<ScaleFactor, Output = f32> + Copy + 'static,
|
||||
T: Mul<ScaleFactor, Output = f32> + Copy + Ord + 'static,
|
||||
f32: AsPrimitive<T>,
|
||||
{
|
||||
/// Produce a `Size<T>` scaled with the input scaling options.
|
||||
/// The size will at minimum be 1x1, and at a maximum 16384x16384.
|
||||
fn scale_viewport(self, scaling: Scale2D, viewport: Size<T>, original: Size<T>) -> Size<T>;
|
||||
}
|
||||
|
||||
impl<T> ViewportSize<T> for Size<T>
|
||||
where
|
||||
T: Mul<ScaleFactor, Output = f32> + Copy + 'static,
|
||||
T: Mul<ScaleFactor, Output = f32> + Copy + Ord + 'static,
|
||||
f32: AsPrimitive<T>,
|
||||
{
|
||||
fn scale_viewport(self, scaling: Scale2D, viewport: Size<T>, original: Size<T>) -> Size<T>
|
||||
where
|
||||
T: Mul<ScaleFactor, Output = f32> + Copy + 'static,
|
||||
T: Mul<ScaleFactor, Output = f32> + Copy + Ord + 'static,
|
||||
f32: AsPrimitive<T>,
|
||||
{
|
||||
scaling::scale(scaling, self, viewport, original)
|
||||
|
@ -35,6 +38,7 @@ pub trait MipmapSize<T> {
|
|||
fn calculate_miplevels(self) -> T;
|
||||
|
||||
/// Scale the size according to the given mipmap level.
|
||||
/// The size will at minimum be 1x1, and at a maximum 16384x16384.
|
||||
fn scale_mipmap(self, miplevel: T) -> Size<T>;
|
||||
}
|
||||
|
||||
|
@ -59,7 +63,7 @@ impl MipmapSize<u32> for Size<u32> {
|
|||
|
||||
fn scale<T>(scaling: Scale2D, source: Size<T>, viewport: Size<T>, original: Size<T>) -> Size<T>
|
||||
where
|
||||
T: Mul<ScaleFactor, Output = f32> + Copy + 'static,
|
||||
T: Mul<ScaleFactor, Output = f32> + Copy + Ord + 'static,
|
||||
f32: AsPrimitive<T>,
|
||||
{
|
||||
let width = match scaling.x {
|
||||
|
@ -101,8 +105,14 @@ where
|
|||
};
|
||||
|
||||
Size {
|
||||
width: width.round().as_(),
|
||||
height: height.round().as_(),
|
||||
width: std::cmp::min(
|
||||
std::cmp::max(width.round().as_(), 1f32.as_()),
|
||||
MAX_TEXEL_SIZE.as_(),
|
||||
),
|
||||
height: std::cmp::min(
|
||||
std::cmp::max(height.round().as_(), 1f32.as_()),
|
||||
MAX_TEXEL_SIZE.as_(),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue