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