lib: use a faster hashmap implementation
This commit is contained in:
parent
dc1ab35d89
commit
b348e8591f
45
Cargo.lock
generated
45
Cargo.lock
generated
|
@ -1243,6 +1243,15 @@ dependencies = [
|
||||||
"crunchy",
|
"crunchy",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "halfbrown"
|
||||||
|
version = "0.2.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5681137554ddff44396e5f149892c769d45301dd9aa19c51602a89ee214cb0ec"
|
||||||
|
dependencies = [
|
||||||
|
"hashbrown 0.13.2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hashbrown"
|
name = "hashbrown"
|
||||||
version = "0.12.3"
|
version = "0.12.3"
|
||||||
|
@ -1252,6 +1261,15 @@ dependencies = [
|
||||||
"ahash 0.7.8",
|
"ahash 0.7.8",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hashbrown"
|
||||||
|
version = "0.13.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e"
|
||||||
|
dependencies = [
|
||||||
|
"ahash 0.8.7",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hashbrown"
|
name = "hashbrown"
|
||||||
version = "0.14.3"
|
version = "0.14.3"
|
||||||
|
@ -1580,8 +1598,10 @@ version = "0.2.0-rc.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ash",
|
"ash",
|
||||||
"gl",
|
"gl",
|
||||||
|
"halfbrown",
|
||||||
"icrate 0.1.0",
|
"icrate 0.1.0",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
|
"rustc-hash",
|
||||||
"wgpu-types",
|
"wgpu-types",
|
||||||
"windows 0.48.0",
|
"windows 0.48.0",
|
||||||
]
|
]
|
||||||
|
@ -1596,7 +1616,6 @@ dependencies = [
|
||||||
"librashader-presets 0.1.4",
|
"librashader-presets 0.1.4",
|
||||||
"nom",
|
"nom",
|
||||||
"rayon",
|
"rayon",
|
||||||
"rustc-hash",
|
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1625,7 +1644,6 @@ dependencies = [
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"os_str_bytes",
|
"os_str_bytes",
|
||||||
"regex",
|
"regex",
|
||||||
"rustc-hash",
|
|
||||||
"rustversion",
|
"rustversion",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
@ -1663,7 +1681,7 @@ dependencies = [
|
||||||
"librashader-presets 0.2.0-rc.1",
|
"librashader-presets 0.2.0-rc.1",
|
||||||
"librashader-reflect",
|
"librashader-reflect",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"rustc-hash",
|
"tinymap",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1680,7 +1698,6 @@ dependencies = [
|
||||||
"librashader-reflect",
|
"librashader-reflect",
|
||||||
"librashader-runtime",
|
"librashader-runtime",
|
||||||
"rayon",
|
"rayon",
|
||||||
"rustc-hash",
|
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"windows 0.48.0",
|
"windows 0.48.0",
|
||||||
]
|
]
|
||||||
|
@ -1702,7 +1719,6 @@ dependencies = [
|
||||||
"librashader-runtime",
|
"librashader-runtime",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"rayon",
|
"rayon",
|
||||||
"rustc-hash",
|
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"widestring",
|
"widestring",
|
||||||
"windows 0.48.0",
|
"windows 0.48.0",
|
||||||
|
@ -1724,7 +1740,6 @@ dependencies = [
|
||||||
"librashader-runtime",
|
"librashader-runtime",
|
||||||
"librashader-spirv-cross",
|
"librashader-spirv-cross",
|
||||||
"rayon",
|
"rayon",
|
||||||
"rustc-hash",
|
|
||||||
"sptr",
|
"sptr",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
@ -1743,7 +1758,6 @@ dependencies = [
|
||||||
"librashader-runtime",
|
"librashader-runtime",
|
||||||
"objc2 0.5.0",
|
"objc2 0.5.0",
|
||||||
"rayon",
|
"rayon",
|
||||||
"rustc-hash",
|
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1767,7 +1781,6 @@ dependencies = [
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"raw-window-handle 0.5.2",
|
"raw-window-handle 0.5.2",
|
||||||
"rayon",
|
"rayon",
|
||||||
"rustc-hash",
|
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"winit",
|
"winit",
|
||||||
]
|
]
|
||||||
|
@ -1790,7 +1803,6 @@ dependencies = [
|
||||||
"pollster",
|
"pollster",
|
||||||
"raw-window-handle 0.6.0",
|
"raw-window-handle 0.6.0",
|
||||||
"rayon",
|
"rayon",
|
||||||
"rustc-hash",
|
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"wgpu",
|
"wgpu",
|
||||||
"winit",
|
"winit",
|
||||||
|
@ -2992,6 +3004,21 @@ dependencies = [
|
||||||
"strict-num",
|
"strict-num",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tinymap"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "606a25fa775ecddf21f83f373a0724423f364b5aaacac14f0cce4cf4c976ff43"
|
||||||
|
dependencies = [
|
||||||
|
"tinyvec",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tinyvec"
|
||||||
|
version = "1.6.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml"
|
name = "toml"
|
||||||
version = "0.5.11"
|
version = "0.5.11"
|
||||||
|
|
|
@ -25,8 +25,9 @@ metal = ["icrate"]
|
||||||
gl = { version = "0.14.0", optional = true }
|
gl = { version = "0.14.0", optional = true }
|
||||||
ash = { version = "0.37", optional = true }
|
ash = { version = "0.37", optional = true }
|
||||||
wgpu-types = { version = "0.19.0", optional = true }
|
wgpu-types = { version = "0.19.0", optional = true }
|
||||||
|
|
||||||
num-traits = "0.2.15"
|
num-traits = "0.2.15"
|
||||||
|
rustc-hash = "1.1.0"
|
||||||
|
halfbrown = "0.2.4"
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies.windows]
|
[target.'cfg(windows)'.dependencies.windows]
|
||||||
optional = true
|
optional = true
|
||||||
|
|
|
@ -29,6 +29,9 @@ pub mod metal;
|
||||||
|
|
||||||
mod viewport;
|
mod viewport;
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub mod map;
|
||||||
|
|
||||||
pub use viewport::Viewport;
|
pub use viewport::Viewport;
|
||||||
|
|
||||||
use num_traits::AsPrimitive;
|
use num_traits::AsPrimitive;
|
||||||
|
|
5
librashader-common/src/map.rs
Normal file
5
librashader-common/src/map.rs
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
/// Fast optimized hash map type for small sets.
|
||||||
|
pub type FastHashMap<K, V> = halfbrown::SizedHashMap<K, V,
|
||||||
|
core::hash::BuildHasherDefault<rustc_hash::FxHasher>, 32>;
|
||||||
|
|
||||||
|
pub use halfbrown;
|
|
@ -15,7 +15,6 @@ description = "RetroArch shaders for all."
|
||||||
thiserror = "1.0.37"
|
thiserror = "1.0.37"
|
||||||
nom = "7.1.1"
|
nom = "7.1.1"
|
||||||
librashader-common = { path = "../librashader-common", version = "0.2.0-rc.1" }
|
librashader-common = { path = "../librashader-common", version = "0.2.0-rc.1" }
|
||||||
rustc-hash = "1.1.0"
|
|
||||||
encoding_rs = "0.8.31"
|
encoding_rs = "0.8.31"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
|
|
@ -16,7 +16,7 @@ mod stage;
|
||||||
use crate::include::read_source;
|
use crate::include::read_source;
|
||||||
pub use error::*;
|
pub use error::*;
|
||||||
use librashader_common::ImageFormat;
|
use librashader_common::ImageFormat;
|
||||||
use rustc_hash::FxHashMap;
|
use librashader_common::map::FastHashMap;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
/// The source file for a single shader pass.
|
/// The source file for a single shader pass.
|
||||||
|
@ -32,7 +32,7 @@ pub struct ShaderSource {
|
||||||
pub name: Option<String>,
|
pub name: Option<String>,
|
||||||
|
|
||||||
/// The list of shader parameters found in the shader source.
|
/// The list of shader parameters found in the shader source.
|
||||||
pub parameters: FxHashMap<String, ShaderParameter>,
|
pub parameters: FastHashMap<String, ShaderParameter>,
|
||||||
|
|
||||||
/// The image format the shader expects.
|
/// The image format the shader expects.
|
||||||
pub format: ImageFormat,
|
pub format: ImageFormat,
|
||||||
|
@ -82,7 +82,7 @@ pub(crate) fn load_shader_source(path: impl AsRef<Path>) -> Result<ShaderSource,
|
||||||
let source = read_source(path)?;
|
let source = read_source(path)?;
|
||||||
let meta = pragma::parse_pragma_meta(&source)?;
|
let meta = pragma::parse_pragma_meta(&source)?;
|
||||||
let text = stage::process_stages(&source)?;
|
let text = stage::process_stages(&source)?;
|
||||||
let parameters = FxHashMap::from_iter(meta.parameters.into_iter().map(|p| (p.id.clone(), p)));
|
let parameters = FastHashMap::from_iter(meta.parameters.into_iter().map(|p| (p.id.clone(), p)));
|
||||||
|
|
||||||
Ok(ShaderSource {
|
Ok(ShaderSource {
|
||||||
vertex: text.vertex,
|
vertex: text.vertex,
|
||||||
|
|
|
@ -20,7 +20,6 @@ num-traits = "0.2"
|
||||||
once_cell = "1"
|
once_cell = "1"
|
||||||
# we don't need unicode
|
# we don't need unicode
|
||||||
regex = { version = "1", default-features = false, features = ["perf"] }
|
regex = { version = "1", default-features = false, features = ["perf"] }
|
||||||
rustc-hash = "1.1.0"
|
|
||||||
|
|
||||||
rustversion = "1.0"
|
rustversion = "1.0"
|
||||||
os_str_bytes = { version = "6", features = ["conversions"] }
|
os_str_bytes = { version = "6", features = ["conversions"] }
|
||||||
|
|
|
@ -6,11 +6,11 @@
|
||||||
//! [RetroArch#15023](https://github.com/libretro/RetroArch/pull/15023).
|
//! [RetroArch#15023](https://github.com/libretro/RetroArch/pull/15023).
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use regex::bytes::Regex;
|
use regex::bytes::Regex;
|
||||||
use rustc_hash::FxHashMap;
|
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::fmt::{Debug, Display, Formatter};
|
use std::fmt::{Debug, Display, Formatter};
|
||||||
use std::ops::Add;
|
use std::ops::Add;
|
||||||
use std::path::{Component, Path, PathBuf};
|
use std::path::{Component, Path, PathBuf};
|
||||||
|
use librashader_common::map::FastHashMap;
|
||||||
|
|
||||||
/// Valid video driver or runtime. This list is non-exhaustive.
|
/// Valid video driver or runtime. This list is non-exhaustive.
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
|
@ -326,8 +326,8 @@ impl WildcardContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_hashmap(mut self) -> FxHashMap<String, String> {
|
pub fn to_hashmap(mut self) -> FastHashMap<String, String> {
|
||||||
let mut map = FxHashMap::default();
|
let mut map = FastHashMap::default();
|
||||||
let last_user_rot = self
|
let last_user_rot = self
|
||||||
.0
|
.0
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -361,7 +361,7 @@ impl WildcardContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustversion::since(1.74)]
|
#[rustversion::since(1.74)]
|
||||||
pub(crate) fn apply_context(path: &mut PathBuf, context: &FxHashMap<String, String>) {
|
pub(crate) fn apply_context(path: &mut PathBuf, context: &FastHashMap<String, String>) {
|
||||||
use std::ffi::{OsStr, OsString};
|
use std::ffi::{OsStr, OsString};
|
||||||
|
|
||||||
static WILDCARD_REGEX: Lazy<Regex> = Lazy::new(|| Regex::new("\\$([A-Z-_]+)\\$").unwrap());
|
static WILDCARD_REGEX: Lazy<Regex> = Lazy::new(|| Regex::new("\\$([A-Z-_]+)\\$").unwrap());
|
||||||
|
@ -409,7 +409,7 @@ pub(crate) fn apply_context(path: &mut PathBuf, context: &FxHashMap<String, Stri
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustversion::before(1.74)]
|
#[rustversion::before(1.74)]
|
||||||
pub(crate) fn apply_context(path: &mut PathBuf, context: &FxHashMap<String, String>) {
|
pub(crate) fn apply_context(path: &mut PathBuf, context: &FastHashMap<String, String>) {
|
||||||
use os_str_bytes::RawOsStr;
|
use os_str_bytes::RawOsStr;
|
||||||
static WILDCARD_REGEX: Lazy<Regex> = Lazy::new(|| Regex::new("\\$([A-Z-_]+)\\$").unwrap());
|
static WILDCARD_REGEX: Lazy<Regex> = Lazy::new(|| Regex::new("\\$([A-Z-_]+)\\$").unwrap());
|
||||||
if context.is_empty() {
|
if context.is_empty() {
|
||||||
|
|
|
@ -11,11 +11,11 @@ use num_traits::cast::ToPrimitive;
|
||||||
|
|
||||||
use crate::parse::token::do_lex;
|
use crate::parse::token::do_lex;
|
||||||
use librashader_common::{FilterMode, WrapMode};
|
use librashader_common::{FilterMode, WrapMode};
|
||||||
use rustc_hash::FxHashMap;
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
use librashader_common::map::FastHashMap;
|
||||||
|
|
||||||
use crate::context::{apply_context, WildcardContext};
|
use crate::context::{apply_context, WildcardContext};
|
||||||
use crate::extract_if::MakeExtractIf;
|
use crate::extract_if::MakeExtractIf;
|
||||||
|
@ -156,7 +156,7 @@ pub const SHADER_MAX_REFERENCE_DEPTH: usize = 16;
|
||||||
fn load_child_reference_strings(
|
fn load_child_reference_strings(
|
||||||
root_references: Vec<PathBuf>,
|
root_references: Vec<PathBuf>,
|
||||||
root_path: impl AsRef<Path>,
|
root_path: impl AsRef<Path>,
|
||||||
context: &FxHashMap<String, String>,
|
context: &FastHashMap<String, String>,
|
||||||
) -> Result<Vec<(PathBuf, String)>, ParsePresetError> {
|
) -> Result<Vec<(PathBuf, String)>, ParsePresetError> {
|
||||||
let root_path = root_path.as_ref();
|
let root_path = root_path.as_ref();
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ pub(crate) fn parse_preset(
|
||||||
pub fn parse_values(
|
pub fn parse_values(
|
||||||
mut tokens: Vec<Token>,
|
mut tokens: Vec<Token>,
|
||||||
root_path: impl AsRef<Path>,
|
root_path: impl AsRef<Path>,
|
||||||
context: FxHashMap<String, String>,
|
context: FastHashMap<String, String>,
|
||||||
) -> Result<Vec<Value>, ParsePresetError> {
|
) -> Result<Vec<Value>, ParsePresetError> {
|
||||||
let mut root_path = root_path.as_ref().to_path_buf();
|
let mut root_path = root_path.as_ref().to_path_buf();
|
||||||
if root_path.is_relative() {
|
if root_path.is_relative() {
|
||||||
|
|
|
@ -17,7 +17,6 @@ bytemuck = "1.13.0"
|
||||||
|
|
||||||
thiserror = "1.0.37"
|
thiserror = "1.0.37"
|
||||||
bitflags = "2.4.2"
|
bitflags = "2.4.2"
|
||||||
rustc-hash = "1.1.0"
|
|
||||||
|
|
||||||
librashader-common = { path = "../librashader-common", version = "0.2.0-rc.1" }
|
librashader-common = { path = "../librashader-common", version = "0.2.0-rc.1" }
|
||||||
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.0-rc.1" }
|
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.0-rc.1" }
|
||||||
|
@ -33,6 +32,7 @@ serde = { version = "1.0", features = ["derive"], optional = true }
|
||||||
|
|
||||||
indexmap = { version = "2.1.0", features = [] }
|
indexmap = { version = "2.1.0", features = [] }
|
||||||
matches = { version = "0.1.10", features = [] }
|
matches = { version = "0.1.10", features = [] }
|
||||||
|
rustc-hash = "1.1.0"
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies.spirv-to-dxil]
|
[target.'cfg(windows)'.dependencies.spirv-to-dxil]
|
||||||
version = "0.4"
|
version = "0.4"
|
||||||
|
|
|
@ -7,7 +7,7 @@ use crate::reflect::semantics::{
|
||||||
};
|
};
|
||||||
use librashader_preprocess::{PreprocessError, ShaderSource};
|
use librashader_preprocess::{PreprocessError, ShaderSource};
|
||||||
use librashader_presets::{ShaderPassConfig, TextureConfig};
|
use librashader_presets::{ShaderPassConfig, TextureConfig};
|
||||||
use rustc_hash::FxHashMap;
|
use librashader_common::map::FastHashMap;
|
||||||
|
|
||||||
/// Artifacts of a reflected and compiled shader pass.
|
/// Artifacts of a reflected and compiled shader pass.
|
||||||
///
|
///
|
||||||
|
@ -80,8 +80,8 @@ where
|
||||||
E: From<ShaderReflectError>,
|
E: From<ShaderReflectError>,
|
||||||
E: From<ShaderCompileError>,
|
E: From<ShaderCompileError>,
|
||||||
{
|
{
|
||||||
let mut uniform_semantics: FxHashMap<String, UniformSemantic> = Default::default();
|
let mut uniform_semantics: FastHashMap<String, UniformSemantic> = Default::default();
|
||||||
let mut texture_semantics: FxHashMap<String, Semantic<TextureSemantics>> = Default::default();
|
let mut texture_semantics: FastHashMap<String, Semantic<TextureSemantics>> = Default::default();
|
||||||
|
|
||||||
let passes = passes
|
let passes = passes
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
@ -119,8 +119,8 @@ where
|
||||||
|
|
||||||
/// Insert the available semantics for the input pass config into the provided semantic maps.
|
/// Insert the available semantics for the input pass config into the provided semantic maps.
|
||||||
fn insert_pass_semantics(
|
fn insert_pass_semantics(
|
||||||
uniform_semantics: &mut FxHashMap<String, UniformSemantic>,
|
uniform_semantics: &mut FastHashMap<String, UniformSemantic>,
|
||||||
texture_semantics: &mut FxHashMap<String, Semantic<TextureSemantics>>,
|
texture_semantics: &mut FastHashMap<String, Semantic<TextureSemantics>>,
|
||||||
config: &ShaderPassConfig,
|
config: &ShaderPassConfig,
|
||||||
) {
|
) {
|
||||||
let Some(alias) = &config.alias else {
|
let Some(alias) = &config.alias else {
|
||||||
|
@ -170,8 +170,8 @@ fn insert_pass_semantics(
|
||||||
/// Insert the available semantics for the input texture config into the provided semantic maps.
|
/// Insert the available semantics for the input texture config into the provided semantic maps.
|
||||||
fn insert_lut_semantics(
|
fn insert_lut_semantics(
|
||||||
textures: &[TextureConfig],
|
textures: &[TextureConfig],
|
||||||
uniform_semantics: &mut FxHashMap<String, UniformSemantic>,
|
uniform_semantics: &mut FastHashMap<String, UniformSemantic>,
|
||||||
texture_semantics: &mut FxHashMap<String, Semantic<TextureSemantics>>,
|
texture_semantics: &mut FastHashMap<String, Semantic<TextureSemantics>>,
|
||||||
) {
|
) {
|
||||||
for (index, texture) in textures.iter().enumerate() {
|
for (index, texture) in textures.iter().enumerate() {
|
||||||
texture_semantics.insert(
|
texture_semantics.insert(
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use bitflags::bitflags;
|
use bitflags::bitflags;
|
||||||
use rustc_hash::FxHashMap;
|
use librashader_common::map::FastHashMap;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
/// The maximum number of bindings allowed in a shader.
|
/// The maximum number of bindings allowed in a shader.
|
||||||
|
@ -321,7 +321,7 @@ pub trait TextureSemanticMap {
|
||||||
fn get_texture_semantic(&self, name: &str) -> Option<Semantic<TextureSemantics>>;
|
fn get_texture_semantic(&self, name: &str) -> Option<Semantic<TextureSemantics>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TextureSemanticMap for FxHashMap<String, UniformSemantic> {
|
impl TextureSemanticMap for FastHashMap<String, UniformSemantic> {
|
||||||
fn get_texture_semantic(&self, name: &str) -> Option<Semantic<TextureSemantics>> {
|
fn get_texture_semantic(&self, name: &str) -> Option<Semantic<TextureSemantics>> {
|
||||||
match self.get(name) {
|
match self.get(name) {
|
||||||
None => {
|
None => {
|
||||||
|
@ -353,7 +353,7 @@ impl TextureSemanticMap for FxHashMap<String, UniformSemantic> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TextureSemanticMap for FxHashMap<String, Semantic<TextureSemantics>> {
|
impl TextureSemanticMap for FastHashMap<String, Semantic<TextureSemantics>> {
|
||||||
fn get_texture_semantic(&self, name: &str) -> Option<Semantic<TextureSemantics>> {
|
fn get_texture_semantic(&self, name: &str) -> Option<Semantic<TextureSemantics>> {
|
||||||
match self.get(name) {
|
match self.get(name) {
|
||||||
None => {
|
None => {
|
||||||
|
@ -390,7 +390,7 @@ pub trait UniqueSemanticMap {
|
||||||
fn get_unique_semantic(&self, name: &str) -> Option<Semantic<UniqueSemantics, ()>>;
|
fn get_unique_semantic(&self, name: &str) -> Option<Semantic<UniqueSemantics, ()>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UniqueSemanticMap for FxHashMap<String, UniformSemantic> {
|
impl UniqueSemanticMap for FastHashMap<String, UniformSemantic> {
|
||||||
fn get_unique_semantic(&self, name: &str) -> Option<Semantic<UniqueSemantics, ()>> {
|
fn get_unique_semantic(&self, name: &str) -> Option<Semantic<UniqueSemantics, ()>> {
|
||||||
match self.get(name) {
|
match self.get(name) {
|
||||||
// existing uniforms in the semantic map have priority
|
// existing uniforms in the semantic map have priority
|
||||||
|
@ -448,9 +448,9 @@ pub enum UniformSemantic {
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct ShaderSemantics {
|
pub struct ShaderSemantics {
|
||||||
/// A map of uniform names to filter chain semantics.
|
/// A map of uniform names to filter chain semantics.
|
||||||
pub uniform_semantics: FxHashMap<String, UniformSemantic>,
|
pub uniform_semantics: FastHashMap<String, UniformSemantic>,
|
||||||
/// A map of texture names to filter chain semantics.
|
/// A map of texture names to filter chain semantics.
|
||||||
pub texture_semantics: FxHashMap<String, Semantic<TextureSemantics>>,
|
pub texture_semantics: FastHashMap<String, Semantic<TextureSemantics>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The binding of a uniform after the shader has been linked.
|
/// The binding of a uniform after the shader has been linked.
|
||||||
|
@ -483,11 +483,11 @@ impl From<Semantic<TextureSemantics>> for UniformBinding {
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct BindingMeta {
|
pub struct BindingMeta {
|
||||||
/// A map of parameter names to uniform binding metadata.
|
/// A map of parameter names to uniform binding metadata.
|
||||||
pub parameter_meta: FxHashMap<String, VariableMeta>,
|
pub parameter_meta: FastHashMap<String, VariableMeta>,
|
||||||
/// A map of unique semantics to uniform binding metadata.
|
/// A map of unique semantics to uniform binding metadata.
|
||||||
pub unique_meta: FxHashMap<UniqueSemantics, VariableMeta>,
|
pub unique_meta: FastHashMap<UniqueSemantics, VariableMeta>,
|
||||||
/// A map of texture semantics to texture binding points.
|
/// A map of texture semantics to texture binding points.
|
||||||
pub texture_meta: FxHashMap<Semantic<TextureSemantics>, TextureBinding>,
|
pub texture_meta: FastHashMap<Semantic<TextureSemantics>, TextureBinding>,
|
||||||
/// A map of texture semantics to texture size uniform binding metadata.
|
/// A map of texture semantics to texture size uniform binding metadata.
|
||||||
pub texture_size_meta: FxHashMap<Semantic<TextureSemantics>, TextureSizeMeta>,
|
pub texture_size_meta: FastHashMap<Semantic<TextureSemantics>, TextureSizeMeta>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ librashader-runtime = { path = "../librashader-runtime", version = "0.2.0-rc.1"
|
||||||
librashader-cache = { path = "../librashader-cache", version = "0.2.0-rc.1", features = ["d3d"] }
|
librashader-cache = { path = "../librashader-cache", version = "0.2.0-rc.1", features = ["d3d"] }
|
||||||
|
|
||||||
thiserror = "1.0.37"
|
thiserror = "1.0.37"
|
||||||
rustc-hash = "1.1.0"
|
|
||||||
bytemuck = "1.12.3"
|
bytemuck = "1.12.3"
|
||||||
rayon = "1.6.1"
|
rayon = "1.6.1"
|
||||||
array-concat = "0.5.2"
|
array-concat = "0.5.2"
|
||||||
|
|
|
@ -8,7 +8,7 @@ use librashader_reflect::front::{SpirvCompilation};
|
||||||
use librashader_reflect::reflect::semantics::ShaderSemantics;
|
use librashader_reflect::reflect::semantics::ShaderSemantics;
|
||||||
use librashader_reflect::reflect::ReflectShader;
|
use librashader_reflect::reflect::ReflectShader;
|
||||||
use librashader_runtime::image::{Image, ImageError, UVDirection};
|
use librashader_runtime::image::{Image, ImageError, UVDirection};
|
||||||
use rustc_hash::FxHashMap;
|
use librashader_common::map::FastHashMap;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
@ -44,7 +44,7 @@ use windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||||
|
|
||||||
pub struct FilterMutable {
|
pub struct FilterMutable {
|
||||||
pub(crate) passes_enabled: usize,
|
pub(crate) passes_enabled: usize,
|
||||||
pub(crate) parameters: FxHashMap<String, f32>,
|
pub(crate) parameters: FastHashMap<String, f32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A Direct3D 11 filter chain.
|
/// A Direct3D 11 filter chain.
|
||||||
|
@ -65,7 +65,7 @@ pub(crate) struct Direct3D11 {
|
||||||
|
|
||||||
pub(crate) struct FilterCommon {
|
pub(crate) struct FilterCommon {
|
||||||
pub(crate) d3d11: Direct3D11,
|
pub(crate) d3d11: Direct3D11,
|
||||||
pub(crate) luts: FxHashMap<usize, LutTexture>,
|
pub(crate) luts: FastHashMap<usize, LutTexture>,
|
||||||
pub samplers: SamplerSet,
|
pub samplers: SamplerSet,
|
||||||
pub output_textures: Box<[Option<InputTexture>]>,
|
pub output_textures: Box<[Option<InputTexture>]>,
|
||||||
pub feedback_textures: Box<[Option<InputTexture>]>,
|
pub feedback_textures: Box<[Option<InputTexture>]>,
|
||||||
|
@ -355,8 +355,8 @@ impl FilterChainD3D11 {
|
||||||
device: &ID3D11Device,
|
device: &ID3D11Device,
|
||||||
context: &ID3D11DeviceContext,
|
context: &ID3D11DeviceContext,
|
||||||
textures: &[TextureConfig],
|
textures: &[TextureConfig],
|
||||||
) -> error::Result<FxHashMap<usize, LutTexture>> {
|
) -> error::Result<FastHashMap<usize, LutTexture>> {
|
||||||
let mut luts = FxHashMap::default();
|
let mut luts = FastHashMap::default();
|
||||||
let images = textures
|
let images = textures
|
||||||
.par_iter()
|
.par_iter()
|
||||||
.map(|texture| Image::load(&texture.path, UVDirection::TopLeft))
|
.map(|texture| Image::load(&texture.path, UVDirection::TopLeft))
|
||||||
|
|
|
@ -9,7 +9,7 @@ use librashader_reflect::reflect::semantics::{
|
||||||
BindingStage, MemberOffset, TextureBinding, UniformBinding,
|
BindingStage, MemberOffset, TextureBinding, UniformBinding,
|
||||||
};
|
};
|
||||||
use librashader_reflect::reflect::ShaderReflection;
|
use librashader_reflect::reflect::ShaderReflection;
|
||||||
use rustc_hash::FxHashMap;
|
use librashader_common::map::FastHashMap;
|
||||||
|
|
||||||
use librashader_runtime::binding::{BindSemantics, TextureInput, UniformInputs};
|
use librashader_runtime::binding::{BindSemantics, TextureInput, UniformInputs};
|
||||||
use librashader_runtime::filter_pass::FilterPassMeta;
|
use librashader_runtime::filter_pass::FilterPassMeta;
|
||||||
|
@ -39,7 +39,7 @@ pub struct FilterPass {
|
||||||
pub vertex_layout: ID3D11InputLayout,
|
pub vertex_layout: ID3D11InputLayout,
|
||||||
pub pixel_shader: ID3D11PixelShader,
|
pub pixel_shader: ID3D11PixelShader,
|
||||||
|
|
||||||
pub uniform_bindings: FxHashMap<UniformBinding, MemberOffset>,
|
pub uniform_bindings: FastHashMap<UniformBinding, MemberOffset>,
|
||||||
|
|
||||||
pub uniform_storage: UniformStorage,
|
pub uniform_storage: UniformStorage,
|
||||||
pub uniform_buffer: Option<ConstantBufferBinding>,
|
pub uniform_buffer: Option<ConstantBufferBinding>,
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
use crate::error::{assume_d3d11_init, Result};
|
use crate::error::{assume_d3d11_init, Result};
|
||||||
use librashader_common::{FilterMode, WrapMode};
|
use librashader_common::{FilterMode, WrapMode};
|
||||||
use rustc_hash::FxHashMap;
|
use librashader_common::map::FastHashMap;
|
||||||
use windows::Win32::Graphics::Direct3D11::{
|
use windows::Win32::Graphics::Direct3D11::{
|
||||||
ID3D11Device, ID3D11SamplerState, D3D11_COMPARISON_NEVER, D3D11_FLOAT32_MAX,
|
ID3D11Device, ID3D11SamplerState, D3D11_COMPARISON_NEVER, D3D11_FLOAT32_MAX,
|
||||||
D3D11_SAMPLER_DESC, D3D11_TEXTURE_ADDRESS_MODE,
|
D3D11_SAMPLER_DESC, D3D11_TEXTURE_ADDRESS_MODE,
|
||||||
};
|
};
|
||||||
pub struct SamplerSet {
|
pub struct SamplerSet {
|
||||||
samplers: FxHashMap<(WrapMode, FilterMode), ID3D11SamplerState>,
|
samplers: FastHashMap<(WrapMode, FilterMode), ID3D11SamplerState>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SamplerSet {
|
impl SamplerSet {
|
||||||
|
@ -18,7 +18,7 @@ impl SamplerSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(device: &ID3D11Device) -> Result<SamplerSet> {
|
pub fn new(device: &ID3D11Device) -> Result<SamplerSet> {
|
||||||
let mut samplers = FxHashMap::default();
|
let mut samplers = FastHashMap::default();
|
||||||
let wrap_modes = &[
|
let wrap_modes = &[
|
||||||
WrapMode::ClampToBorder,
|
WrapMode::ClampToBorder,
|
||||||
WrapMode::ClampToEdge,
|
WrapMode::ClampToEdge,
|
||||||
|
|
|
@ -22,7 +22,6 @@ librashader-cache = { path = "../librashader-cache", version = "0.2.0-rc.1", fea
|
||||||
thiserror = "1.0.37"
|
thiserror = "1.0.37"
|
||||||
parking_lot = "0.12.1"
|
parking_lot = "0.12.1"
|
||||||
|
|
||||||
rustc-hash = "1.1.0"
|
|
||||||
bytemuck = { version = "1.12.3", features = ["derive"] }
|
bytemuck = { version = "1.12.3", features = ["derive"] }
|
||||||
array-init = "2.1.0"
|
array-init = "2.1.0"
|
||||||
bitvec = "1.0.1"
|
bitvec = "1.0.1"
|
||||||
|
|
|
@ -26,7 +26,7 @@ use librashader_runtime::binding::{BindingUtil, TextureInput};
|
||||||
use librashader_runtime::image::{Image, ImageError, UVDirection};
|
use librashader_runtime::image::{Image, ImageError, UVDirection};
|
||||||
use librashader_runtime::quad::QuadType;
|
use librashader_runtime::quad::QuadType;
|
||||||
use librashader_runtime::uniforms::UniformStorage;
|
use librashader_runtime::uniforms::UniformStorage;
|
||||||
use rustc_hash::FxHashMap;
|
use librashader_common::map::FastHashMap;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::mem::ManuallyDrop;
|
use std::mem::ManuallyDrop;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
@ -57,7 +57,7 @@ const MIPMAP_RESERVED_WORKHEAP_DESCRIPTORS: usize = 4096;
|
||||||
|
|
||||||
pub struct FilterMutable {
|
pub struct FilterMutable {
|
||||||
pub(crate) passes_enabled: usize,
|
pub(crate) passes_enabled: usize,
|
||||||
pub(crate) parameters: FxHashMap<String, f32>,
|
pub(crate) parameters: FastHashMap<String, f32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A Direct3D 12 filter chain.
|
/// A Direct3D 12 filter chain.
|
||||||
|
@ -89,7 +89,7 @@ pub(crate) struct FilterCommon {
|
||||||
pub history_textures: Box<[Option<InputTexture>]>,
|
pub history_textures: Box<[Option<InputTexture>]>,
|
||||||
pub config: FilterMutable,
|
pub config: FilterMutable,
|
||||||
// pub disable_mipmaps: bool,
|
// pub disable_mipmaps: bool,
|
||||||
pub luts: FxHashMap<usize, LutTexture>,
|
pub luts: FastHashMap<usize, LutTexture>,
|
||||||
pub mipmap_gen: D3D12MipmapGen,
|
pub mipmap_gen: D3D12MipmapGen,
|
||||||
pub root_signature: D3D12RootSignature,
|
pub root_signature: D3D12RootSignature,
|
||||||
pub draw_quad: DrawQuad,
|
pub draw_quad: DrawQuad,
|
||||||
|
@ -371,11 +371,11 @@ impl FilterChainD3D12 {
|
||||||
mipmap_heap: &mut D3D12DescriptorHeap<ResourceWorkHeap>,
|
mipmap_heap: &mut D3D12DescriptorHeap<ResourceWorkHeap>,
|
||||||
gc: &mut FrameResiduals,
|
gc: &mut FrameResiduals,
|
||||||
textures: &[TextureConfig],
|
textures: &[TextureConfig],
|
||||||
) -> error::Result<FxHashMap<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)?;
|
||||||
|
|
||||||
let mut luts = FxHashMap::default();
|
let mut luts = FastHashMap::default();
|
||||||
let images = textures
|
let images = textures
|
||||||
.par_iter()
|
.par_iter()
|
||||||
.map(|texture| Image::load(&texture.path, UVDirection::TopLeft))
|
.map(|texture| Image::load(&texture.path, UVDirection::TopLeft))
|
||||||
|
|
|
@ -16,7 +16,7 @@ use librashader_runtime::filter_pass::FilterPassMeta;
|
||||||
use librashader_runtime::quad::QuadType;
|
use librashader_runtime::quad::QuadType;
|
||||||
use librashader_runtime::render_target::RenderTarget;
|
use librashader_runtime::render_target::RenderTarget;
|
||||||
use librashader_runtime::uniforms::{NoUniformBinder, UniformStorage};
|
use librashader_runtime::uniforms::{NoUniformBinder, UniformStorage};
|
||||||
use rustc_hash::FxHashMap;
|
use librashader_common::map::FastHashMap;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use windows::core::ComInterface;
|
use windows::core::ComInterface;
|
||||||
use windows::Win32::Foundation::RECT;
|
use windows::Win32::Foundation::RECT;
|
||||||
|
@ -31,7 +31,7 @@ pub(crate) struct FilterPass {
|
||||||
pub(crate) pipeline: D3D12GraphicsPipeline,
|
pub(crate) pipeline: D3D12GraphicsPipeline,
|
||||||
pub(crate) reflection: ShaderReflection,
|
pub(crate) reflection: ShaderReflection,
|
||||||
pub(crate) config: ShaderPassConfig,
|
pub(crate) config: ShaderPassConfig,
|
||||||
pub(crate) uniform_bindings: FxHashMap<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>,
|
||||||
pub(crate) texture_heap: [D3D12DescriptorHeapSlot<ResourceWorkHeap>; 16],
|
pub(crate) texture_heap: [D3D12DescriptorHeapSlot<ResourceWorkHeap>; 16],
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::descriptor_heap::{D3D12DescriptorHeap, D3D12DescriptorHeapSlot, SamplerPaletteHeap};
|
use crate::descriptor_heap::{D3D12DescriptorHeap, D3D12DescriptorHeapSlot, SamplerPaletteHeap};
|
||||||
use crate::error;
|
use crate::error;
|
||||||
use librashader_common::{FilterMode, WrapMode};
|
use librashader_common::{FilterMode, WrapMode};
|
||||||
use rustc_hash::FxHashMap;
|
use librashader_common::map::FastHashMap;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use windows::Win32::Graphics::Direct3D12::{
|
use windows::Win32::Graphics::Direct3D12::{
|
||||||
ID3D12Device, D3D12_COMPARISON_FUNC_NEVER, D3D12_FLOAT32_MAX, D3D12_SAMPLER_DESC,
|
ID3D12Device, D3D12_COMPARISON_FUNC_NEVER, D3D12_FLOAT32_MAX, D3D12_SAMPLER_DESC,
|
||||||
|
@ -9,7 +9,7 @@ use windows::Win32::Graphics::Direct3D12::{
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct SamplerSet {
|
pub struct SamplerSet {
|
||||||
samplers: FxHashMap<(WrapMode, FilterMode), D3D12DescriptorHeapSlot<SamplerPaletteHeap>>,
|
samplers: FastHashMap<(WrapMode, FilterMode), D3D12DescriptorHeapSlot<SamplerPaletteHeap>>,
|
||||||
_heap: D3D12DescriptorHeap<SamplerPaletteHeap>,
|
_heap: D3D12DescriptorHeap<SamplerPaletteHeap>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ impl SamplerSet {
|
||||||
unsafe { self.samplers.get(&(wrap, filter)).unwrap_unchecked() }
|
unsafe { self.samplers.get(&(wrap, filter)).unwrap_unchecked() }
|
||||||
}
|
}
|
||||||
pub fn new(device: &ID3D12Device) -> error::Result<SamplerSet> {
|
pub fn new(device: &ID3D12Device) -> error::Result<SamplerSet> {
|
||||||
let mut samplers = FxHashMap::default();
|
let mut samplers = FastHashMap::default();
|
||||||
let wrap_modes = &[
|
let wrap_modes = &[
|
||||||
WrapMode::ClampToBorder,
|
WrapMode::ClampToBorder,
|
||||||
WrapMode::ClampToEdge,
|
WrapMode::ClampToEdge,
|
||||||
|
|
|
@ -20,7 +20,6 @@ librashader-runtime = { path = "../librashader-runtime" , version = "0.2.0-rc.1"
|
||||||
librashader-cache = { path = "../librashader-cache", version = "0.2.0-rc.1" }
|
librashader-cache = { path = "../librashader-cache", version = "0.2.0-rc.1" }
|
||||||
spirv_cross = { package = "librashader-spirv-cross", version = "0.25.1" }
|
spirv_cross = { package = "librashader-spirv-cross", version = "0.25.1" }
|
||||||
|
|
||||||
rustc-hash = "1.1.0"
|
|
||||||
gl = "0.14.0"
|
gl = "0.14.0"
|
||||||
bytemuck = { version = "1.12.3", features = ["derive"] }
|
bytemuck = { version = "1.12.3", features = ["derive"] }
|
||||||
thiserror = "1.0.37"
|
thiserror = "1.0.37"
|
||||||
|
|
|
@ -27,7 +27,7 @@ use librashader_runtime::binding::BindingUtil;
|
||||||
use librashader_runtime::framebuffer::FramebufferInit;
|
use librashader_runtime::framebuffer::FramebufferInit;
|
||||||
use librashader_runtime::render_target::RenderTarget;
|
use librashader_runtime::render_target::RenderTarget;
|
||||||
use librashader_runtime::scaling::ScaleFramebuffer;
|
use librashader_runtime::scaling::ScaleFramebuffer;
|
||||||
use rustc_hash::FxHashMap;
|
use librashader_common::map::FastHashMap;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
|
@ -51,7 +51,7 @@ pub(crate) struct FilterChainImpl<T: GLInterface> {
|
||||||
pub(crate) struct FilterCommon {
|
pub(crate) struct FilterCommon {
|
||||||
// semantics: ReflectSemantics,
|
// semantics: ReflectSemantics,
|
||||||
pub config: FilterMutable,
|
pub config: FilterMutable,
|
||||||
pub luts: FxHashMap<usize, InputTexture>,
|
pub luts: FastHashMap<usize, InputTexture>,
|
||||||
pub samplers: SamplerSet,
|
pub samplers: SamplerSet,
|
||||||
pub output_textures: Box<[InputTexture]>,
|
pub output_textures: Box<[InputTexture]>,
|
||||||
pub feedback_textures: Box<[InputTexture]>,
|
pub feedback_textures: Box<[InputTexture]>,
|
||||||
|
@ -61,7 +61,7 @@ pub(crate) struct FilterCommon {
|
||||||
|
|
||||||
pub struct FilterMutable {
|
pub struct FilterMutable {
|
||||||
pub(crate) passes_enabled: usize,
|
pub(crate) passes_enabled: usize,
|
||||||
pub(crate) parameters: FxHashMap<String, f32>,
|
pub(crate) parameters: FastHashMap<String, f32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: GLInterface> FilterChainImpl<T> {
|
impl<T: GLInterface> FilterChainImpl<T> {
|
||||||
|
|
|
@ -3,7 +3,6 @@ use crate::filter_chain::inner::FilterChainDispatch;
|
||||||
use crate::gl::GLInterface;
|
use crate::gl::GLInterface;
|
||||||
use crate::FilterChainGL;
|
use crate::FilterChainGL;
|
||||||
use librashader_runtime::parameters::FilterChainParameters;
|
use librashader_runtime::parameters::FilterChainParameters;
|
||||||
use std::collections::hash_map::Iter;
|
|
||||||
|
|
||||||
impl AsRef<dyn FilterChainParameters + 'static> for FilterChainDispatch {
|
impl AsRef<dyn FilterChainParameters + 'static> for FilterChainDispatch {
|
||||||
fn as_ref<'a>(&'a self) -> &'a (dyn FilterChainParameters + 'static) {
|
fn as_ref<'a>(&'a self) -> &'a (dyn FilterChainParameters + 'static) {
|
||||||
|
@ -32,7 +31,7 @@ impl FilterChainParameters for FilterChainGL {
|
||||||
self.filter.as_mut().set_enabled_pass_count(count)
|
self.filter.as_mut().set_enabled_pass_count(count)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn enumerate_parameters(&self) -> Iter<String, f32> {
|
fn enumerate_parameters(&self) -> ::librashader_common::map::halfbrown::Iter<String, f32> {
|
||||||
self.filter.as_ref().enumerate_parameters()
|
self.filter.as_ref().enumerate_parameters()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +53,7 @@ impl<T: GLInterface> FilterChainParameters for FilterChainImpl<T> {
|
||||||
self.common.config.passes_enabled = count
|
self.common.config.passes_enabled = count
|
||||||
}
|
}
|
||||||
|
|
||||||
fn enumerate_parameters(&self) -> Iter<String, f32> {
|
fn enumerate_parameters(&self) -> ::librashader_common::map::halfbrown::Iter<String, f32> {
|
||||||
self.common.config.parameters.iter()
|
self.common.config.parameters.iter()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ use librashader_reflect::reflect::semantics::{MemberOffset, TextureBinding, Unif
|
||||||
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;
|
||||||
use librashader_runtime::render_target::RenderTarget;
|
use librashader_runtime::render_target::RenderTarget;
|
||||||
use rustc_hash::FxHashMap;
|
use librashader_common::map::FastHashMap;
|
||||||
|
|
||||||
use crate::binding::{GlUniformBinder, GlUniformStorage, UniformLocation, VariableLocation};
|
use crate::binding::{GlUniformBinder, GlUniformStorage, UniformLocation, VariableLocation};
|
||||||
use crate::filter_chain::FilterCommon;
|
use crate::filter_chain::FilterCommon;
|
||||||
|
@ -36,7 +36,7 @@ pub(crate) struct FilterPass<T: GLInterface> {
|
||||||
pub ubo_location: UniformLocation<GLuint>,
|
pub ubo_location: UniformLocation<GLuint>,
|
||||||
pub ubo_ring: Option<T::UboRing>,
|
pub ubo_ring: Option<T::UboRing>,
|
||||||
pub(crate) uniform_storage: GlUniformStorage,
|
pub(crate) uniform_storage: GlUniformStorage,
|
||||||
pub uniform_bindings: FxHashMap<UniformBinding, UniformOffset>,
|
pub uniform_bindings: FastHashMap<UniformBinding, UniformOffset>,
|
||||||
pub source: ShaderSource,
|
pub source: ShaderSource,
|
||||||
pub config: ShaderPassConfig,
|
pub config: ShaderPassConfig,
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,12 +7,12 @@ use librashader_presets::TextureConfig;
|
||||||
use librashader_runtime::image::{Image, ImageError, UVDirection};
|
use librashader_runtime::image::{Image, ImageError, UVDirection};
|
||||||
use librashader_runtime::scaling::MipmapSize;
|
use librashader_runtime::scaling::MipmapSize;
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
use rustc_hash::FxHashMap;
|
use librashader_common::map::FastHashMap;
|
||||||
|
|
||||||
pub struct Gl3LutLoad;
|
pub struct Gl3LutLoad;
|
||||||
impl LoadLut for Gl3LutLoad {
|
impl LoadLut for Gl3LutLoad {
|
||||||
fn load_luts(textures: &[TextureConfig]) -> Result<FxHashMap<usize, InputTexture>> {
|
fn load_luts(textures: &[TextureConfig]) -> Result<FastHashMap<usize, InputTexture>> {
|
||||||
let mut luts = FxHashMap::default();
|
let mut luts = FastHashMap::default();
|
||||||
let pixel_unpack = unsafe {
|
let pixel_unpack = unsafe {
|
||||||
let mut binding = 0;
|
let mut binding = 0;
|
||||||
gl::GetIntegerv(gl::PIXEL_UNPACK_BUFFER_BINDING, &mut binding);
|
gl::GetIntegerv(gl::PIXEL_UNPACK_BUFFER_BINDING, &mut binding);
|
||||||
|
|
|
@ -7,12 +7,12 @@ use librashader_presets::TextureConfig;
|
||||||
use librashader_runtime::image::{Image, ImageError, UVDirection};
|
use librashader_runtime::image::{Image, ImageError, UVDirection};
|
||||||
use librashader_runtime::scaling::MipmapSize;
|
use librashader_runtime::scaling::MipmapSize;
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
use rustc_hash::FxHashMap;
|
use librashader_common::map::FastHashMap;
|
||||||
|
|
||||||
pub struct Gl46LutLoad;
|
pub struct Gl46LutLoad;
|
||||||
impl LoadLut for Gl46LutLoad {
|
impl LoadLut for Gl46LutLoad {
|
||||||
fn load_luts(textures: &[TextureConfig]) -> Result<FxHashMap<usize, InputTexture>> {
|
fn load_luts(textures: &[TextureConfig]) -> Result<FastHashMap<usize, InputTexture>> {
|
||||||
let mut luts = FxHashMap::default();
|
let mut luts = FastHashMap::default();
|
||||||
let pixel_unpack = unsafe {
|
let pixel_unpack = unsafe {
|
||||||
let mut binding = 0;
|
let mut binding = 0;
|
||||||
gl::GetIntegerv(gl::PIXEL_UNPACK_BUFFER_BINDING, &mut binding);
|
gl::GetIntegerv(gl::PIXEL_UNPACK_BUFFER_BINDING, &mut binding);
|
||||||
|
|
|
@ -16,7 +16,7 @@ use librashader_reflect::back::glsl::CrossGlslContext;
|
||||||
use librashader_reflect::back::ShaderCompilerOutput;
|
use librashader_reflect::back::ShaderCompilerOutput;
|
||||||
use librashader_reflect::reflect::semantics::{BufferReflection, TextureBinding};
|
use librashader_reflect::reflect::semantics::{BufferReflection, TextureBinding};
|
||||||
use librashader_runtime::uniforms::UniformStorageAccess;
|
use librashader_runtime::uniforms::UniformStorageAccess;
|
||||||
use rustc_hash::FxHashMap;
|
use librashader_common::map::FastHashMap;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Copy, Clone, Default, Zeroable, Pod)]
|
#[derive(Debug, Copy, Clone, Default, Zeroable, Pod)]
|
||||||
|
@ -46,7 +46,7 @@ pub(crate) static FINAL_VBO_DATA: &[OpenGLVertex; 4] = &[
|
||||||
];
|
];
|
||||||
|
|
||||||
pub(crate) trait LoadLut {
|
pub(crate) trait LoadLut {
|
||||||
fn load_luts(textures: &[TextureConfig]) -> Result<FxHashMap<usize, InputTexture>>;
|
fn load_luts(textures: &[TextureConfig]) -> Result<FastHashMap<usize, InputTexture>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) trait CompileProgram {
|
pub(crate) trait CompileProgram {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use gl::types::{GLenum, GLint, GLuint};
|
use gl::types::{GLenum, GLint, GLuint};
|
||||||
use librashader_common::{FilterMode, WrapMode};
|
use librashader_common::{FilterMode, WrapMode};
|
||||||
use rustc_hash::FxHashMap;
|
use librashader_common::map::FastHashMap;
|
||||||
|
|
||||||
pub struct SamplerSet {
|
pub struct SamplerSet {
|
||||||
// todo: may need to deal with differences in mip filter.
|
// todo: may need to deal with differences in mip filter.
|
||||||
samplers: FxHashMap<(WrapMode, FilterMode, FilterMode), GLuint>,
|
samplers: FastHashMap<(WrapMode, FilterMode, FilterMode), GLuint>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SamplerSet {
|
impl SamplerSet {
|
||||||
|
@ -35,7 +35,7 @@ impl SamplerSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new() -> SamplerSet {
|
pub fn new() -> SamplerSet {
|
||||||
let mut samplers = FxHashMap::default();
|
let mut samplers = FastHashMap::default();
|
||||||
let wrap_modes = &[
|
let wrap_modes = &[
|
||||||
WrapMode::ClampToBorder,
|
WrapMode::ClampToBorder,
|
||||||
WrapMode::ClampToEdge,
|
WrapMode::ClampToEdge,
|
||||||
|
|
|
@ -20,8 +20,6 @@ librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.0-
|
||||||
librashader-reflect = { path = "../librashader-reflect", version = "0.2.0-rc.1" }
|
librashader-reflect = { path = "../librashader-reflect", version = "0.2.0-rc.1" }
|
||||||
librashader-runtime = { path = "../librashader-runtime" , version = "0.2.0-rc.1" }
|
librashader-runtime = { path = "../librashader-runtime" , version = "0.2.0-rc.1" }
|
||||||
|
|
||||||
|
|
||||||
rustc-hash = "1.1.0"
|
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
array-concat = "0.5.2"
|
array-concat = "0.5.2"
|
||||||
bytemuck = { version = "1.12.3", features = ["derive"] }
|
bytemuck = { version = "1.12.3", features = ["derive"] }
|
||||||
|
|
|
@ -35,7 +35,7 @@ use librashader_runtime::uniforms::UniformStorage;
|
||||||
use objc2::rc::Id;
|
use objc2::rc::Id;
|
||||||
use objc2::runtime::ProtocolObject;
|
use objc2::runtime::ProtocolObject;
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
use rustc_hash::FxHashMap;
|
use librashader_common::map::FastHashMap;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::fmt::{Debug, Formatter};
|
use std::fmt::{Debug, Formatter};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
@ -72,14 +72,14 @@ impl Debug for FilterChainMetal {
|
||||||
|
|
||||||
pub struct FilterMutable {
|
pub struct FilterMutable {
|
||||||
pub passes_enabled: usize,
|
pub passes_enabled: usize,
|
||||||
pub(crate) parameters: FxHashMap<String, f32>,
|
pub(crate) parameters: FastHashMap<String, f32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) struct FilterCommon {
|
pub(crate) struct FilterCommon {
|
||||||
pub output_textures: Box<[Option<InputTexture>]>,
|
pub output_textures: Box<[Option<InputTexture>]>,
|
||||||
pub feedback_textures: Box<[Option<InputTexture>]>,
|
pub feedback_textures: Box<[Option<InputTexture>]>,
|
||||||
pub history_textures: Box<[Option<InputTexture>]>,
|
pub history_textures: Box<[Option<InputTexture>]>,
|
||||||
pub luts: FxHashMap<usize, LutTexture>,
|
pub luts: FastHashMap<usize, LutTexture>,
|
||||||
pub samplers: SamplerSet,
|
pub samplers: SamplerSet,
|
||||||
pub config: FilterMutable,
|
pub config: FilterMutable,
|
||||||
pub internal_frame_count: i32,
|
pub internal_frame_count: i32,
|
||||||
|
@ -122,8 +122,8 @@ impl FilterChainMetal {
|
||||||
device: &ProtocolObject<dyn MTLDevice>,
|
device: &ProtocolObject<dyn MTLDevice>,
|
||||||
cmd: &ProtocolObject<dyn MTLCommandBuffer>,
|
cmd: &ProtocolObject<dyn MTLCommandBuffer>,
|
||||||
textures: &[TextureConfig],
|
textures: &[TextureConfig],
|
||||||
) -> error::Result<FxHashMap<usize, LutTexture>> {
|
) -> error::Result<FastHashMap<usize, LutTexture>> {
|
||||||
let mut luts = FxHashMap::default();
|
let mut luts = FastHashMap::default();
|
||||||
|
|
||||||
let mipmapper = cmd
|
let mipmapper = cmd
|
||||||
.blitCommandEncoder()
|
.blitCommandEncoder()
|
||||||
|
|
|
@ -17,7 +17,7 @@ use librashader_runtime::quad::QuadType;
|
||||||
use librashader_runtime::render_target::RenderTarget;
|
use librashader_runtime::render_target::RenderTarget;
|
||||||
use librashader_runtime::uniforms::{NoUniformBinder, UniformStorage};
|
use librashader_runtime::uniforms::{NoUniformBinder, UniformStorage};
|
||||||
use objc2::runtime::ProtocolObject;
|
use objc2::runtime::ProtocolObject;
|
||||||
use rustc_hash::FxHashMap;
|
use librashader_common::map::FastHashMap;
|
||||||
|
|
||||||
impl TextureInput for InputTexture {
|
impl TextureInput for InputTexture {
|
||||||
fn size(&self) -> Size<u32> {
|
fn size(&self) -> Size<u32> {
|
||||||
|
@ -53,7 +53,7 @@ pub struct FilterPass {
|
||||||
pub reflection: ShaderReflection,
|
pub reflection: ShaderReflection,
|
||||||
pub(crate) uniform_storage:
|
pub(crate) uniform_storage:
|
||||||
UniformStorage<NoUniformBinder, Option<()>, MetalBuffer, MetalBuffer>,
|
UniformStorage<NoUniformBinder, Option<()>, MetalBuffer, MetalBuffer>,
|
||||||
pub uniform_bindings: FxHashMap<UniformBinding, MemberOffset>,
|
pub uniform_bindings: FastHashMap<UniformBinding, MemberOffset>,
|
||||||
pub source: ShaderSource,
|
pub source: ShaderSource,
|
||||||
pub config: ShaderPassConfig,
|
pub config: ShaderPassConfig,
|
||||||
pub graphics_pipeline: MetalGraphicsPipeline,
|
pub graphics_pipeline: MetalGraphicsPipeline,
|
||||||
|
|
|
@ -6,14 +6,14 @@ use icrate::Metal::{
|
||||||
use librashader_common::{FilterMode, WrapMode};
|
use librashader_common::{FilterMode, WrapMode};
|
||||||
use objc2::rc::Id;
|
use objc2::rc::Id;
|
||||||
use objc2::runtime::ProtocolObject;
|
use objc2::runtime::ProtocolObject;
|
||||||
use rustc_hash::FxHashMap;
|
use librashader_common::map::FastHashMap;
|
||||||
|
|
||||||
use crate::error::{FilterChainError, Result};
|
use crate::error::{FilterChainError, Result};
|
||||||
|
|
||||||
pub struct SamplerSet {
|
pub struct SamplerSet {
|
||||||
// todo: may need to deal with differences in mip filter.
|
// todo: may need to deal with differences in mip filter.
|
||||||
samplers:
|
samplers:
|
||||||
FxHashMap<(WrapMode, FilterMode, FilterMode), Id<ProtocolObject<dyn MTLSamplerState>>>,
|
FastHashMap<(WrapMode, FilterMode, FilterMode), Id<ProtocolObject<dyn MTLSamplerState>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SamplerSet {
|
impl SamplerSet {
|
||||||
|
@ -37,7 +37,7 @@ impl SamplerSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(device: &ProtocolObject<dyn MTLDevice>) -> Result<SamplerSet> {
|
pub fn new(device: &ProtocolObject<dyn MTLDevice>) -> Result<SamplerSet> {
|
||||||
let mut samplers = FxHashMap::default();
|
let mut samplers = FastHashMap::default();
|
||||||
let wrap_modes = &[
|
let wrap_modes = &[
|
||||||
WrapMode::ClampToBorder,
|
WrapMode::ClampToBorder,
|
||||||
WrapMode::ClampToEdge,
|
WrapMode::ClampToEdge,
|
||||||
|
|
|
@ -21,7 +21,6 @@ librashader-reflect = { path = "../librashader-reflect", version = "0.2.0-rc.1"
|
||||||
librashader-runtime = { path = "../librashader-runtime" , version = "0.2.0-rc.1" }
|
librashader-runtime = { path = "../librashader-runtime" , version = "0.2.0-rc.1" }
|
||||||
librashader-cache = { path = "../librashader-cache", version = "0.2.0-rc.1" }
|
librashader-cache = { path = "../librashader-cache", version = "0.2.0-rc.1" }
|
||||||
|
|
||||||
rustc-hash = "1.1.0"
|
|
||||||
bytemuck = { version = "1.12.3", features = ["derive"] }
|
bytemuck = { version = "1.12.3", features = ["derive"] }
|
||||||
thiserror = "1.0.37"
|
thiserror = "1.0.37"
|
||||||
ash = { version = "0.37", features = ["debug"] }
|
ash = { version = "0.37", features = ["debug"] }
|
||||||
|
|
|
@ -26,7 +26,7 @@ use librashader_runtime::image::{Image, ImageError, UVDirection, BGRA8};
|
||||||
use librashader_runtime::quad::QuadType;
|
use librashader_runtime::quad::QuadType;
|
||||||
use librashader_runtime::uniforms::UniformStorage;
|
use librashader_runtime::uniforms::UniformStorage;
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use rustc_hash::FxHashMap;
|
use librashader_common::map::FastHashMap;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::convert::Infallible;
|
use std::convert::Infallible;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
@ -130,11 +130,11 @@ pub struct FilterChainVulkan {
|
||||||
|
|
||||||
pub struct FilterMutable {
|
pub struct FilterMutable {
|
||||||
pub(crate) passes_enabled: usize,
|
pub(crate) passes_enabled: usize,
|
||||||
pub(crate) parameters: FxHashMap<String, f32>,
|
pub(crate) parameters: FastHashMap<String, f32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) struct FilterCommon {
|
pub(crate) struct FilterCommon {
|
||||||
pub(crate) luts: FxHashMap<usize, LutTexture>,
|
pub(crate) luts: FastHashMap<usize, LutTexture>,
|
||||||
pub samplers: SamplerSet,
|
pub samplers: SamplerSet,
|
||||||
pub(crate) draw_quad: DrawQuad,
|
pub(crate) draw_quad: DrawQuad,
|
||||||
pub output_textures: Box<[Option<InputImage>]>,
|
pub output_textures: Box<[Option<InputImage>]>,
|
||||||
|
@ -482,8 +482,8 @@ impl FilterChainVulkan {
|
||||||
vulkan: &VulkanObjects,
|
vulkan: &VulkanObjects,
|
||||||
command_buffer: vk::CommandBuffer,
|
command_buffer: vk::CommandBuffer,
|
||||||
textures: &[TextureConfig],
|
textures: &[TextureConfig],
|
||||||
) -> error::Result<FxHashMap<usize, LutTexture>> {
|
) -> error::Result<FastHashMap<usize, LutTexture>> {
|
||||||
let mut luts = FxHashMap::default();
|
let mut luts = FastHashMap::default();
|
||||||
let images = textures
|
let images = textures
|
||||||
.par_iter()
|
.par_iter()
|
||||||
.map(|texture| Image::load(&texture.path, UVDirection::TopLeft))
|
.map(|texture| Image::load(&texture.path, UVDirection::TopLeft))
|
||||||
|
|
|
@ -19,7 +19,7 @@ use librashader_runtime::filter_pass::FilterPassMeta;
|
||||||
use librashader_runtime::quad::QuadType;
|
use librashader_runtime::quad::QuadType;
|
||||||
use librashader_runtime::render_target::RenderTarget;
|
use librashader_runtime::render_target::RenderTarget;
|
||||||
use librashader_runtime::uniforms::{NoUniformBinder, UniformStorage, UniformStorageAccess};
|
use librashader_runtime::uniforms::{NoUniformBinder, UniformStorage, UniformStorageAccess};
|
||||||
use rustc_hash::FxHashMap;
|
use librashader_common::map::FastHashMap;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub struct FilterPass {
|
pub struct FilterPass {
|
||||||
|
@ -27,7 +27,7 @@ pub struct FilterPass {
|
||||||
pub reflection: ShaderReflection,
|
pub reflection: ShaderReflection,
|
||||||
// pub(crate) compiled: ShaderCompilerOutput<Vec<u32>>,
|
// pub(crate) compiled: ShaderCompilerOutput<Vec<u32>>,
|
||||||
pub(crate) uniform_storage: UniformStorage<NoUniformBinder, Option<()>, RawVulkanBuffer>,
|
pub(crate) uniform_storage: UniformStorage<NoUniformBinder, Option<()>, RawVulkanBuffer>,
|
||||||
pub uniform_bindings: FxHashMap<UniformBinding, MemberOffset>,
|
pub uniform_bindings: FastHashMap<UniformBinding, MemberOffset>,
|
||||||
pub source: ShaderSource,
|
pub source: ShaderSource,
|
||||||
pub config: ShaderPassConfig,
|
pub config: ShaderPassConfig,
|
||||||
pub graphics_pipeline: VulkanGraphicsPipeline,
|
pub graphics_pipeline: VulkanGraphicsPipeline,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::error;
|
use crate::error;
|
||||||
use ash::vk;
|
use ash::vk;
|
||||||
use librashader_common::{FilterMode, WrapMode};
|
use librashader_common::{FilterMode, WrapMode};
|
||||||
use rustc_hash::FxHashMap;
|
use librashader_common::map::FastHashMap;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub struct VulkanSampler {
|
pub struct VulkanSampler {
|
||||||
|
@ -52,7 +52,7 @@ impl Drop for VulkanSampler {
|
||||||
|
|
||||||
pub struct SamplerSet {
|
pub struct SamplerSet {
|
||||||
// todo: may need to deal with differences in mip filter.
|
// todo: may need to deal with differences in mip filter.
|
||||||
samplers: FxHashMap<(WrapMode, FilterMode, FilterMode), VulkanSampler>,
|
samplers: FastHashMap<(WrapMode, FilterMode, FilterMode), VulkanSampler>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SamplerSet {
|
impl SamplerSet {
|
||||||
|
@ -69,7 +69,7 @@ impl SamplerSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(device: &Arc<ash::Device>) -> error::Result<SamplerSet> {
|
pub fn new(device: &Arc<ash::Device>) -> error::Result<SamplerSet> {
|
||||||
let mut samplers = FxHashMap::default();
|
let mut samplers = FastHashMap::default();
|
||||||
let wrap_modes = &[
|
let wrap_modes = &[
|
||||||
WrapMode::ClampToBorder,
|
WrapMode::ClampToBorder,
|
||||||
WrapMode::ClampToEdge,
|
WrapMode::ClampToEdge,
|
||||||
|
|
|
@ -21,7 +21,6 @@ librashader-reflect = { path = "../librashader-reflect", version = "0.2.0-rc.1",
|
||||||
librashader-runtime = { path = "../librashader-runtime" , version = "0.2.0-rc.1" }
|
librashader-runtime = { path = "../librashader-runtime" , version = "0.2.0-rc.1" }
|
||||||
|
|
||||||
wgpu = { version = "0.19.0", default-features = false, features = ["wgsl"] }
|
wgpu = { version = "0.19.0", default-features = false, features = ["wgsl"] }
|
||||||
rustc-hash = "1.1.0"
|
|
||||||
image = "0.24.7"
|
image = "0.24.7"
|
||||||
thiserror = "1.0.50"
|
thiserror = "1.0.50"
|
||||||
bytemuck = { version = "1.14.0", features = ["derive"] }
|
bytemuck = { version = "1.14.0", features = ["derive"] }
|
||||||
|
|
|
@ -11,7 +11,7 @@ use librashader_runtime::quad::QuadType;
|
||||||
use librashader_runtime::uniforms::UniformStorage;
|
use librashader_runtime::uniforms::UniformStorage;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
use rustc_hash::FxHashMap;
|
use librashader_common::map::FastHashMap;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
@ -64,14 +64,14 @@ pub struct FilterChainWgpu {
|
||||||
|
|
||||||
pub struct FilterMutable {
|
pub struct FilterMutable {
|
||||||
pub passes_enabled: usize,
|
pub passes_enabled: usize,
|
||||||
pub(crate) parameters: FxHashMap<String, f32>,
|
pub(crate) parameters: FastHashMap<String, f32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) struct FilterCommon {
|
pub(crate) struct FilterCommon {
|
||||||
pub output_textures: Box<[Option<InputImage>]>,
|
pub output_textures: Box<[Option<InputImage>]>,
|
||||||
pub feedback_textures: Box<[Option<InputImage>]>,
|
pub feedback_textures: Box<[Option<InputImage>]>,
|
||||||
pub history_textures: Box<[Option<InputImage>]>,
|
pub history_textures: Box<[Option<InputImage>]>,
|
||||||
pub luts: FxHashMap<usize, LutTexture>,
|
pub luts: FastHashMap<usize, LutTexture>,
|
||||||
pub samplers: SamplerSet,
|
pub samplers: SamplerSet,
|
||||||
pub config: FilterMutable,
|
pub config: FilterMutable,
|
||||||
pub internal_frame_count: i32,
|
pub internal_frame_count: i32,
|
||||||
|
@ -216,8 +216,8 @@ impl FilterChainWgpu {
|
||||||
mipmapper: &mut MipmapGen,
|
mipmapper: &mut MipmapGen,
|
||||||
sampler_set: &SamplerSet,
|
sampler_set: &SamplerSet,
|
||||||
textures: &[TextureConfig],
|
textures: &[TextureConfig],
|
||||||
) -> error::Result<FxHashMap<usize, LutTexture>> {
|
) -> error::Result<FastHashMap<usize, LutTexture>> {
|
||||||
let mut luts = FxHashMap::default();
|
let mut luts = FastHashMap::default();
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
let images_iter = textures.par_iter();
|
let images_iter = textures.par_iter();
|
||||||
|
|
|
@ -18,7 +18,7 @@ use librashader_runtime::filter_pass::FilterPassMeta;
|
||||||
use librashader_runtime::quad::QuadType;
|
use librashader_runtime::quad::QuadType;
|
||||||
use librashader_runtime::render_target::RenderTarget;
|
use librashader_runtime::render_target::RenderTarget;
|
||||||
use librashader_runtime::uniforms::{NoUniformBinder, UniformStorage, UniformStorageAccess};
|
use librashader_runtime::uniforms::{NoUniformBinder, UniformStorage, UniformStorageAccess};
|
||||||
use rustc_hash::FxHashMap;
|
use librashader_common::map::FastHashMap;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use wgpu::{BindGroupDescriptor, BindGroupEntry, BindingResource, BufferBinding, ShaderStages};
|
use wgpu::{BindGroupDescriptor, BindGroupEntry, BindingResource, BufferBinding, ShaderStages};
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ pub struct FilterPass {
|
||||||
pub reflection: ShaderReflection,
|
pub reflection: ShaderReflection,
|
||||||
pub(crate) uniform_storage:
|
pub(crate) uniform_storage:
|
||||||
UniformStorage<NoUniformBinder, Option<()>, WgpuStagedBuffer, WgpuStagedBuffer>,
|
UniformStorage<NoUniformBinder, Option<()>, WgpuStagedBuffer, WgpuStagedBuffer>,
|
||||||
pub uniform_bindings: FxHashMap<UniformBinding, MemberOffset>,
|
pub uniform_bindings: FastHashMap<UniformBinding, MemberOffset>,
|
||||||
pub source: ShaderSource,
|
pub source: ShaderSource,
|
||||||
pub config: ShaderPassConfig,
|
pub config: ShaderPassConfig,
|
||||||
pub graphics_pipeline: WgpuGraphicsPipeline,
|
pub graphics_pipeline: WgpuGraphicsPipeline,
|
||||||
|
@ -48,8 +48,8 @@ impl BindSemantics<NoUniformBinder, Option<()>, WgpuStagedBuffer, WgpuStagedBuff
|
||||||
type InputTexture = InputImage;
|
type InputTexture = InputImage;
|
||||||
type SamplerSet = SamplerSet;
|
type SamplerSet = SamplerSet;
|
||||||
type DescriptorSet<'a> = (
|
type DescriptorSet<'a> = (
|
||||||
&'a mut FxHashMap<u32, WgpuArcBinding<wgpu::TextureView>>,
|
&'a mut FastHashMap<u32, WgpuArcBinding<wgpu::TextureView>>,
|
||||||
&'a mut FxHashMap<u32, WgpuArcBinding<wgpu::Sampler>>,
|
&'a mut FastHashMap<u32, WgpuArcBinding<wgpu::Sampler>>,
|
||||||
);
|
);
|
||||||
type DeviceContext = Arc<wgpu::Device>;
|
type DeviceContext = Arc<wgpu::Device>;
|
||||||
type UniformOffset = MemberOffset;
|
type UniformOffset = MemberOffset;
|
||||||
|
@ -97,8 +97,8 @@ impl FilterPass {
|
||||||
output: &RenderTarget<WgpuOutputView>,
|
output: &RenderTarget<WgpuOutputView>,
|
||||||
vbo_type: QuadType,
|
vbo_type: QuadType,
|
||||||
) -> error::Result<()> {
|
) -> error::Result<()> {
|
||||||
let mut main_heap = FxHashMap::default();
|
let mut main_heap = FastHashMap::default();
|
||||||
let mut sampler_heap = FxHashMap::default();
|
let mut sampler_heap = FastHashMap::default();
|
||||||
|
|
||||||
self.build_semantics(
|
self.build_semantics(
|
||||||
pass_index,
|
pass_index,
|
||||||
|
@ -204,8 +204,8 @@ impl FilterPass {
|
||||||
viewport_size: Size<u32>,
|
viewport_size: Size<u32>,
|
||||||
original: &InputImage,
|
original: &InputImage,
|
||||||
source: &InputImage,
|
source: &InputImage,
|
||||||
main_heap: &'a mut FxHashMap<u32, WgpuArcBinding<wgpu::TextureView>>,
|
main_heap: &'a mut FastHashMap<u32, WgpuArcBinding<wgpu::TextureView>>,
|
||||||
sampler_heap: &'a mut FxHashMap<u32, WgpuArcBinding<wgpu::Sampler>>,
|
sampler_heap: &'a mut FastHashMap<u32, WgpuArcBinding<wgpu::Sampler>>,
|
||||||
) {
|
) {
|
||||||
Self::bind_semantics(
|
Self::bind_semantics(
|
||||||
&self.device,
|
&self.device,
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use rustc_hash::FxHashMap;
|
use librashader_common::map::FastHashMap;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub struct MipmapGen {
|
pub struct MipmapGen {
|
||||||
device: Arc<wgpu::Device>,
|
device: Arc<wgpu::Device>,
|
||||||
shader: wgpu::ShaderModule,
|
shader: wgpu::ShaderModule,
|
||||||
pipeline_cache: FxHashMap<wgpu::TextureFormat, wgpu::RenderPipeline>,
|
pipeline_cache: FastHashMap<wgpu::TextureFormat, wgpu::RenderPipeline>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MipmapGen {
|
impl MipmapGen {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use librashader_common::{FilterMode, WrapMode};
|
use librashader_common::{FilterMode, WrapMode};
|
||||||
use rustc_hash::FxHashMap;
|
use librashader_common::map::FastHashMap;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use wgpu::{Sampler, SamplerBorderColor, SamplerDescriptor};
|
use wgpu::{Sampler, SamplerBorderColor, SamplerDescriptor};
|
||||||
|
|
||||||
pub struct SamplerSet {
|
pub struct SamplerSet {
|
||||||
// todo: may need to deal with differences in mip filter.
|
// todo: may need to deal with differences in mip filter.
|
||||||
samplers: FxHashMap<(WrapMode, FilterMode, FilterMode), Arc<Sampler>>,
|
samplers: FastHashMap<(WrapMode, FilterMode, FilterMode), Arc<Sampler>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SamplerSet {
|
impl SamplerSet {
|
||||||
|
@ -25,7 +25,7 @@ impl SamplerSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(device: &wgpu::Device) -> SamplerSet {
|
pub fn new(device: &wgpu::Device) -> SamplerSet {
|
||||||
let mut samplers = FxHashMap::default();
|
let mut samplers = FastHashMap::default();
|
||||||
let wrap_modes = &[
|
let wrap_modes = &[
|
||||||
WrapMode::ClampToBorder,
|
WrapMode::ClampToBorder,
|
||||||
WrapMode::ClampToEdge,
|
WrapMode::ClampToEdge,
|
||||||
|
|
|
@ -17,9 +17,10 @@ librashader-presets = { path = "../librashader-presets", version = "0.2.0-rc.1"
|
||||||
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.0-rc.1" }
|
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.0-rc.1" }
|
||||||
librashader-reflect = { path = "../librashader-reflect", version = "0.2.0-rc.1" }
|
librashader-reflect = { path = "../librashader-reflect", version = "0.2.0-rc.1" }
|
||||||
bytemuck = "1.12.3"
|
bytemuck = "1.12.3"
|
||||||
rustc-hash = "1.1.0"
|
|
||||||
num-traits = "0.2.15"
|
num-traits = "0.2.15"
|
||||||
|
|
||||||
|
tinymap = "0.4.0"
|
||||||
|
|
||||||
[dependencies.image]
|
[dependencies.image]
|
||||||
version = "0.24.5"
|
version = "0.24.5"
|
||||||
features = [
|
features = [
|
||||||
|
|
|
@ -5,10 +5,8 @@ use librashader_reflect::reflect::semantics::{
|
||||||
BindingMeta, MemberOffset, Semantic, TextureBinding, TextureSemantics, UniformBinding,
|
BindingMeta, MemberOffset, Semantic, TextureBinding, TextureSemantics, UniformBinding,
|
||||||
UniformMeta, UniqueSemantics,
|
UniformMeta, UniqueSemantics,
|
||||||
};
|
};
|
||||||
use rustc_hash::FxHashMap;
|
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::hash::BuildHasher;
|
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
|
use librashader_common::map::FastHashMap;
|
||||||
|
|
||||||
/// Trait for input textures used during uniform binding,
|
/// Trait for input textures used during uniform binding,
|
||||||
pub trait TextureInput {
|
pub trait TextureInput {
|
||||||
|
@ -115,14 +113,14 @@ where
|
||||||
uniform_inputs: UniformInputs<'_>,
|
uniform_inputs: UniformInputs<'_>,
|
||||||
original: &Self::InputTexture,
|
original: &Self::InputTexture,
|
||||||
source: &Self::InputTexture,
|
source: &Self::InputTexture,
|
||||||
uniform_bindings: &HashMap<UniformBinding, Self::UniformOffset, impl BuildHasher>,
|
uniform_bindings: &FastHashMap<UniformBinding, Self::UniformOffset>,
|
||||||
texture_meta: &HashMap<Semantic<TextureSemantics>, TextureBinding, impl BuildHasher>,
|
texture_meta: &FastHashMap<Semantic<TextureSemantics>, TextureBinding>,
|
||||||
pass_outputs: impl Iterator<Item = Option<impl AsRef<Self::InputTexture>>>,
|
pass_outputs: impl Iterator<Item = Option<impl AsRef<Self::InputTexture>>>,
|
||||||
pass_feedback: impl Iterator<Item = Option<impl AsRef<Self::InputTexture>>>,
|
pass_feedback: impl Iterator<Item = Option<impl AsRef<Self::InputTexture>>>,
|
||||||
original_history: impl Iterator<Item = Option<impl AsRef<Self::InputTexture>>>,
|
original_history: impl Iterator<Item = Option<impl AsRef<Self::InputTexture>>>,
|
||||||
lookup_textures: impl Iterator<Item = (usize, impl AsRef<Self::InputTexture>)>,
|
lookup_textures: impl Iterator<Item = (usize, impl AsRef<Self::InputTexture>)>,
|
||||||
parameter_defaults: &HashMap<String, ShaderParameter, impl BuildHasher>,
|
parameter_defaults: &FastHashMap<String, ShaderParameter>,
|
||||||
runtime_parameters: &HashMap<String, f32, impl BuildHasher>,
|
runtime_parameters: &FastHashMap<String, f32>,
|
||||||
) {
|
) {
|
||||||
// Bind MVP
|
// Bind MVP
|
||||||
if let Some(offset) = uniform_bindings.get(&UniqueSemantics::MVP.into()) {
|
if let Some(offset) = uniform_bindings.get(&UniqueSemantics::MVP.into()) {
|
||||||
|
@ -328,7 +326,7 @@ pub trait BindingUtil {
|
||||||
fn create_binding_map<T>(
|
fn create_binding_map<T>(
|
||||||
&self,
|
&self,
|
||||||
f: impl Fn(&dyn UniformMeta) -> T,
|
f: impl Fn(&dyn UniformMeta) -> T,
|
||||||
) -> FxHashMap<UniformBinding, T>;
|
) -> FastHashMap<UniformBinding, T>;
|
||||||
|
|
||||||
/// Calculate the number of required images for history.
|
/// Calculate the number of required images for history.
|
||||||
fn calculate_required_history<'a>(pass_meta: impl Iterator<Item = &'a Self>) -> usize
|
fn calculate_required_history<'a>(pass_meta: impl Iterator<Item = &'a Self>) -> usize
|
||||||
|
@ -340,8 +338,8 @@ impl BindingUtil for BindingMeta {
|
||||||
fn create_binding_map<T>(
|
fn create_binding_map<T>(
|
||||||
&self,
|
&self,
|
||||||
f: impl Fn(&dyn UniformMeta) -> T,
|
f: impl Fn(&dyn UniformMeta) -> T,
|
||||||
) -> FxHashMap<UniformBinding, T> {
|
) -> FastHashMap<UniformBinding, T> {
|
||||||
let mut uniform_bindings = FxHashMap::default();
|
let mut uniform_bindings = FastHashMap::default();
|
||||||
for param in self.parameter_meta.values() {
|
for param in self.parameter_meta.values() {
|
||||||
uniform_bindings.insert(UniformBinding::Parameter(param.id.clone()), f(param));
|
uniform_bindings.insert(UniformBinding::Parameter(param.id.clone()), f(param));
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ pub trait FilterChainParameters {
|
||||||
fn set_enabled_pass_count(&mut self, count: usize);
|
fn set_enabled_pass_count(&mut self, count: usize);
|
||||||
|
|
||||||
/// Enumerates the active parameters as well as their values in the current filter chain.
|
/// Enumerates the active parameters as well as their values in the current filter chain.
|
||||||
fn enumerate_parameters(&self) -> std::collections::hash_map::Iter<String, f32>;
|
fn enumerate_parameters<'a>(&'a self) -> ::librashader_common::map::halfbrown::Iter<String, f32>;
|
||||||
|
|
||||||
/// Get the value of the given parameter if present.
|
/// Get the value of the given parameter if present.
|
||||||
fn get_parameter(&self, parameter: &str) -> Option<f32>;
|
fn get_parameter(&self, parameter: &str) -> Option<f32>;
|
||||||
|
@ -30,7 +30,7 @@ macro_rules! impl_filter_chain_parameters {
|
||||||
self.common.config.passes_enabled = count
|
self.common.config.passes_enabled = count
|
||||||
}
|
}
|
||||||
|
|
||||||
fn enumerate_parameters(&self) -> ::std::collections::hash_map::Iter<String, f32> {
|
fn enumerate_parameters<'a>(&'a self) -> ::librashader_common::map::halfbrown::Iter<String, f32> {
|
||||||
self.common.config.parameters.iter()
|
self.common.config.parameters.iter()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,9 @@ pub mod presets {
|
||||||
let iters: Result<Vec<Vec<ShaderParameter>>, PreprocessError> = preset
|
let iters: Result<Vec<Vec<ShaderParameter>>, PreprocessError> = preset
|
||||||
.shaders
|
.shaders
|
||||||
.iter()
|
.iter()
|
||||||
.map(|s| ShaderSource::load(&s.name).map(|s| s.parameters.into_values().collect()))
|
.map(|s| ShaderSource::load(&s.name).map(|s|
|
||||||
|
s.parameters.into_iter()
|
||||||
|
.map(|(_,v)| v).collect()))
|
||||||
.collect();
|
.collect();
|
||||||
let iters = iters?;
|
let iters = iters?;
|
||||||
Ok(iters.into_iter().flatten())
|
Ok(iters.into_iter().flatten())
|
||||||
|
|
Loading…
Reference in a new issue