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;
|
||||
|
||||
|
|
|
@ -75,28 +75,34 @@ pub(crate) struct FilterCommon {
|
|||
pub(crate) draw_quad: DrawQuad,
|
||||
}
|
||||
|
||||
type ShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<HLSL, SpirvCompilation, SpirvCross> + Send>;
|
||||
fn compile_passes(
|
||||
shaders: Vec<ShaderPassConfig>,
|
||||
textures: &[TextureConfig],
|
||||
disable_cache: bool,
|
||||
) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> {
|
||||
let (passes, semantics) = if !disable_cache {
|
||||
HLSL::compile_preset_passes::<
|
||||
CachedCompilation<SpirvCompilation>,
|
||||
SpirvCross,
|
||||
FilterChainError,
|
||||
>(shaders, &textures)?
|
||||
} else {
|
||||
HLSL::compile_preset_passes::<SpirvCompilation, SpirvCross, FilterChainError>(
|
||||
shaders, &textures,
|
||||
)?
|
||||
};
|
||||
mod compile {
|
||||
use super::*;
|
||||
pub type ShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<HLSL, SpirvCompilation, SpirvCross> + Send>;
|
||||
|
||||
Ok((passes, semantics))
|
||||
pub fn compile_passes(
|
||||
shaders: Vec<ShaderPassConfig>,
|
||||
textures: &[TextureConfig],
|
||||
disable_cache: bool,
|
||||
) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> {
|
||||
let (passes, semantics) = if !disable_cache {
|
||||
HLSL::compile_preset_passes::<
|
||||
CachedCompilation<SpirvCompilation>,
|
||||
SpirvCross,
|
||||
FilterChainError,
|
||||
>(shaders, &textures)?
|
||||
} else {
|
||||
HLSL::compile_preset_passes::<SpirvCompilation, SpirvCross, FilterChainError>(
|
||||
shaders, &textures,
|
||||
)?
|
||||
};
|
||||
|
||||
Ok((passes, semantics))
|
||||
}
|
||||
}
|
||||
|
||||
use compile::{compile_passes, ShaderPassMeta};
|
||||
|
||||
impl FilterChainD3D11 {
|
||||
/// Load the shader preset at the given path into a filter chain.
|
||||
pub unsafe fn load_from_path(
|
||||
|
|
|
@ -146,49 +146,57 @@ impl Drop for FrameResiduals {
|
|||
}
|
||||
}
|
||||
|
||||
type DxilShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<DXIL, SpirvCompilation, SpirvCross> + Send>;
|
||||
fn compile_passes_dxil(
|
||||
shaders: Vec<ShaderPassConfig>,
|
||||
textures: &[TextureConfig],
|
||||
disable_cache: bool,
|
||||
) -> Result<(Vec<DxilShaderPassMeta>, ShaderSemantics), FilterChainError> {
|
||||
let (passes, semantics) = if !disable_cache {
|
||||
DXIL::compile_preset_passes::<
|
||||
CachedCompilation<SpirvCompilation>,
|
||||
SpirvCross,
|
||||
FilterChainError,
|
||||
>(shaders, &textures)?
|
||||
} else {
|
||||
DXIL::compile_preset_passes::<SpirvCompilation, SpirvCross, FilterChainError>(
|
||||
shaders, &textures,
|
||||
)?
|
||||
};
|
||||
mod compile {
|
||||
use super::*;
|
||||
pub type DxilShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<DXIL, SpirvCompilation, SpirvCross> + Send>;
|
||||
|
||||
Ok((passes, semantics))
|
||||
}
|
||||
type HlslShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<HLSL, SpirvCompilation, SpirvCross> + Send>;
|
||||
fn compile_passes_hlsl(
|
||||
shaders: Vec<ShaderPassConfig>,
|
||||
textures: &[TextureConfig],
|
||||
disable_cache: bool,
|
||||
) -> Result<(Vec<HlslShaderPassMeta>, ShaderSemantics), FilterChainError> {
|
||||
let (passes, semantics) = if !disable_cache {
|
||||
HLSL::compile_preset_passes::<
|
||||
CachedCompilation<SpirvCompilation>,
|
||||
SpirvCross,
|
||||
FilterChainError,
|
||||
>(shaders, &textures)?
|
||||
} else {
|
||||
HLSL::compile_preset_passes::<SpirvCompilation, SpirvCross, FilterChainError>(
|
||||
shaders, &textures,
|
||||
)?
|
||||
};
|
||||
pub fn compile_passes_dxil(
|
||||
shaders: Vec<ShaderPassConfig>,
|
||||
textures: &[TextureConfig],
|
||||
disable_cache: bool,
|
||||
) -> Result<(Vec<DxilShaderPassMeta>, ShaderSemantics), FilterChainError> {
|
||||
let (passes, semantics) = if !disable_cache {
|
||||
DXIL::compile_preset_passes::<
|
||||
CachedCompilation<SpirvCompilation>,
|
||||
SpirvCross,
|
||||
FilterChainError,
|
||||
>(shaders, &textures)?
|
||||
} else {
|
||||
DXIL::compile_preset_passes::<SpirvCompilation, SpirvCross, FilterChainError>(
|
||||
shaders, &textures,
|
||||
)?
|
||||
};
|
||||
|
||||
Ok((passes, semantics))
|
||||
Ok((passes, semantics))
|
||||
}
|
||||
|
||||
pub type HlslShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<HLSL, SpirvCompilation, SpirvCross> + Send>;
|
||||
|
||||
pub fn compile_passes_hlsl(
|
||||
shaders: Vec<ShaderPassConfig>,
|
||||
textures: &[TextureConfig],
|
||||
disable_cache: bool,
|
||||
) -> Result<(Vec<HlslShaderPassMeta>, ShaderSemantics), FilterChainError> {
|
||||
let (passes, semantics) = if !disable_cache {
|
||||
HLSL::compile_preset_passes::<
|
||||
CachedCompilation<SpirvCompilation>,
|
||||
SpirvCross,
|
||||
FilterChainError,
|
||||
>(shaders, &textures)?
|
||||
} else {
|
||||
HLSL::compile_preset_passes::<SpirvCompilation, SpirvCross, FilterChainError>(
|
||||
shaders, &textures,
|
||||
)?
|
||||
};
|
||||
|
||||
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.
|
||||
pub unsafe fn load_from_path(
|
||||
|
|
|
@ -63,29 +63,34 @@ pub struct FilterChainD3D9 {
|
|||
default_options: FrameOptionsD3D9,
|
||||
}
|
||||
|
||||
type ShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<HLSL, SpirvCompilation, SpirvCross> + Send>;
|
||||
mod compile {
|
||||
use super::*;
|
||||
pub type ShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<HLSL, SpirvCompilation, SpirvCross> + Send>;
|
||||
|
||||
fn compile_passes(
|
||||
shaders: Vec<ShaderPassConfig>,
|
||||
textures: &[TextureConfig],
|
||||
disable_cache: bool,
|
||||
) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> {
|
||||
let (passes, semantics) = if !disable_cache {
|
||||
HLSL::compile_preset_passes::<
|
||||
CachedCompilation<SpirvCompilation>,
|
||||
SpirvCross,
|
||||
FilterChainError,
|
||||
>(shaders, &textures)?
|
||||
} else {
|
||||
HLSL::compile_preset_passes::<SpirvCompilation, SpirvCross, FilterChainError>(
|
||||
shaders, &textures,
|
||||
)?
|
||||
};
|
||||
pub fn compile_passes(
|
||||
shaders: Vec<ShaderPassConfig>,
|
||||
textures: &[TextureConfig],
|
||||
disable_cache: bool,
|
||||
) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> {
|
||||
let (passes, semantics) = if !disable_cache {
|
||||
HLSL::compile_preset_passes::<
|
||||
CachedCompilation<SpirvCompilation>,
|
||||
SpirvCross,
|
||||
FilterChainError,
|
||||
>(shaders, &textures)?
|
||||
} else {
|
||||
HLSL::compile_preset_passes::<SpirvCompilation, SpirvCross, FilterChainError>(
|
||||
shaders, &textures,
|
||||
)?
|
||||
};
|
||||
|
||||
Ok((passes, semantics))
|
||||
Ok((passes, semantics))
|
||||
}
|
||||
}
|
||||
|
||||
use compile::{compile_passes, ShaderPassMeta};
|
||||
|
||||
impl FilterChainD3D9 {
|
||||
fn init_passes(
|
||||
device: &IDirect3DDevice9,
|
||||
|
|
|
@ -92,28 +92,34 @@ impl<T: GLInterface> FilterChainImpl<T> {
|
|||
}
|
||||
}
|
||||
|
||||
type ShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<GLSL, SpirvCompilation, SpirvCross>>;
|
||||
fn compile_passes(
|
||||
shaders: Vec<ShaderPassConfig>,
|
||||
textures: &[TextureConfig],
|
||||
disable_cache: bool,
|
||||
) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> {
|
||||
let (passes, semantics) = if !disable_cache {
|
||||
GLSL::compile_preset_passes::<
|
||||
CachedCompilation<SpirvCompilation>,
|
||||
SpirvCross,
|
||||
FilterChainError,
|
||||
>(shaders, &textures)?
|
||||
} else {
|
||||
GLSL::compile_preset_passes::<SpirvCompilation, SpirvCross, FilterChainError>(
|
||||
shaders, &textures,
|
||||
)?
|
||||
};
|
||||
mod compile {
|
||||
use super::*;
|
||||
pub type ShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<GLSL, SpirvCompilation, SpirvCross>>;
|
||||
|
||||
Ok((passes, semantics))
|
||||
pub fn compile_passes(
|
||||
shaders: Vec<ShaderPassConfig>,
|
||||
textures: &[TextureConfig],
|
||||
disable_cache: bool,
|
||||
) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> {
|
||||
let (passes, semantics) = if !disable_cache {
|
||||
GLSL::compile_preset_passes::<
|
||||
CachedCompilation<SpirvCompilation>,
|
||||
SpirvCross,
|
||||
FilterChainError,
|
||||
>(shaders, &textures)?
|
||||
} else {
|
||||
GLSL::compile_preset_passes::<SpirvCompilation, SpirvCross, FilterChainError>(
|
||||
shaders, &textures,
|
||||
)?
|
||||
};
|
||||
|
||||
Ok((passes, semantics))
|
||||
}
|
||||
}
|
||||
|
||||
use compile::{compile_passes, ShaderPassMeta};
|
||||
|
||||
impl<T: GLInterface> FilterChainImpl<T> {
|
||||
/// Load a filter chain from a pre-parsed `ShaderPreset`.
|
||||
pub(crate) unsafe fn load_from_preset(
|
||||
|
|
|
@ -187,4 +187,4 @@ impl FramebufferInterface for Gl46Framebuffer {
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,19 +40,25 @@ use std::collections::VecDeque;
|
|||
use std::fmt::{Debug, Formatter};
|
||||
use std::path::Path;
|
||||
|
||||
type ShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<MSL, SpirvCompilation, SpirvCross> + Send>;
|
||||
fn compile_passes(
|
||||
shaders: Vec<ShaderPassConfig>,
|
||||
textures: &[TextureConfig],
|
||||
) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> {
|
||||
let (passes, semantics) =
|
||||
MSL::compile_preset_passes::<SpirvCompilation, SpirvCross, FilterChainError>(
|
||||
shaders, &textures,
|
||||
)?;
|
||||
Ok((passes, semantics))
|
||||
mod compile {
|
||||
use super::*;
|
||||
pub type ShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<MSL, SpirvCompilation, SpirvCross> + Send>;
|
||||
|
||||
pub fn compile_passes(
|
||||
shaders: Vec<ShaderPassConfig>,
|
||||
textures: &[TextureConfig],
|
||||
) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> {
|
||||
let (passes, semantics) =
|
||||
MSL::compile_preset_passes::<SpirvCompilation, SpirvCross, FilterChainError>(
|
||||
shaders, &textures,
|
||||
)?;
|
||||
Ok((passes, semantics))
|
||||
}
|
||||
}
|
||||
|
||||
use compile::{compile_passes, ShaderPassMeta};
|
||||
|
||||
/// A Metal filter chain.
|
||||
pub struct FilterChainMetal {
|
||||
pub(crate) common: FilterCommon,
|
||||
|
|
|
@ -209,28 +209,34 @@ impl Drop for FrameResiduals {
|
|||
}
|
||||
}
|
||||
|
||||
type ShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<SPIRV, SpirvCompilation, SpirvCross> + Send>;
|
||||
fn compile_passes(
|
||||
shaders: Vec<ShaderPassConfig>,
|
||||
textures: &[TextureConfig],
|
||||
disable_cache: bool,
|
||||
) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> {
|
||||
let (passes, semantics) = if !disable_cache {
|
||||
SPIRV::compile_preset_passes::<
|
||||
CachedCompilation<SpirvCompilation>,
|
||||
SpirvCross,
|
||||
FilterChainError,
|
||||
>(shaders, &textures)?
|
||||
} else {
|
||||
SPIRV::compile_preset_passes::<SpirvCompilation, SpirvCross, FilterChainError>(
|
||||
shaders, &textures,
|
||||
)?
|
||||
};
|
||||
mod compile {
|
||||
use super::*;
|
||||
pub type ShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<SPIRV, SpirvCompilation, SpirvCross> + Send>;
|
||||
|
||||
Ok((passes, semantics))
|
||||
pub fn compile_passes(
|
||||
shaders: Vec<ShaderPassConfig>,
|
||||
textures: &[TextureConfig],
|
||||
disable_cache: bool,
|
||||
) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> {
|
||||
let (passes, semantics) = if !disable_cache {
|
||||
SPIRV::compile_preset_passes::<
|
||||
CachedCompilation<SpirvCompilation>,
|
||||
SpirvCross,
|
||||
FilterChainError,
|
||||
>(shaders, &textures)?
|
||||
} else {
|
||||
SPIRV::compile_preset_passes::<SpirvCompilation, SpirvCross, FilterChainError>(
|
||||
shaders, &textures,
|
||||
)?
|
||||
};
|
||||
|
||||
Ok((passes, semantics))
|
||||
}
|
||||
}
|
||||
|
||||
use compile::{compile_passes, ShaderPassMeta};
|
||||
|
||||
impl FilterChainVulkan {
|
||||
/// Load the shader preset at the given path into a filter chain.
|
||||
pub unsafe fn load_from_path<V, E>(
|
||||
|
|
|
@ -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,19 +38,25 @@ use crate::options::{FilterChainOptionsWgpu, FrameOptionsWgpu};
|
|||
use crate::samplers::SamplerSet;
|
||||
use crate::texture::{InputImage, OwnedImage};
|
||||
|
||||
type ShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<WGSL, SpirvCompilation, Naga> + Send>;
|
||||
fn compile_passes(
|
||||
shaders: Vec<ShaderPassConfig>,
|
||||
textures: &[TextureConfig],
|
||||
) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> {
|
||||
let (passes, semantics) =
|
||||
WGSL::compile_preset_passes::<SpirvCompilation, Naga, FilterChainError>(
|
||||
shaders, &textures,
|
||||
)?;
|
||||
Ok((passes, semantics))
|
||||
mod compile {
|
||||
use super::*;
|
||||
pub type ShaderPassMeta =
|
||||
ShaderPassArtifact<impl CompileReflectShader<WGSL, SpirvCompilation, Naga> + Send>;
|
||||
|
||||
pub fn compile_passes(
|
||||
shaders: Vec<ShaderPassConfig>,
|
||||
textures: &[TextureConfig],
|
||||
) -> Result<(Vec<ShaderPassMeta>, ShaderSemantics), FilterChainError> {
|
||||
let (passes, semantics) =
|
||||
WGSL::compile_preset_passes::<SpirvCompilation, Naga, FilterChainError>(
|
||||
shaders, &textures,
|
||||
)?;
|
||||
Ok((passes, semantics))
|
||||
}
|
||||
}
|
||||
|
||||
use compile::{compile_passes, ShaderPassMeta};
|
||||
|
||||
/// A wgpu filter chain.
|
||||
pub struct FilterChainWgpu {
|
||||
pub(crate) common: FilterCommon,
|
||||
|
|
|
@ -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