diff --git a/Cargo.lock b/Cargo.lock index 60cedf4..cb139c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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" diff --git a/librashader-common/Cargo.toml b/librashader-common/Cargo.toml index 73aca4f..f183cc9 100644 --- a/librashader-common/Cargo.toml +++ b/librashader-common/Cargo.toml @@ -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 diff --git a/librashader-common/src/lib.rs b/librashader-common/src/lib.rs index 653d8c7..b7a4dd9 100644 --- a/librashader-common/src/lib.rs +++ b/librashader-common/src/lib.rs @@ -29,6 +29,9 @@ pub mod metal; mod viewport; +#[doc(hidden)] +pub mod map; + pub use viewport::Viewport; use num_traits::AsPrimitive; diff --git a/librashader-common/src/map.rs b/librashader-common/src/map.rs new file mode 100644 index 0000000..6aabaed --- /dev/null +++ b/librashader-common/src/map.rs @@ -0,0 +1,5 @@ +/// Fast optimized hash map type for small sets. +pub type FastHashMap = halfbrown::SizedHashMap, 32>; + +pub use halfbrown; \ No newline at end of file diff --git a/librashader-preprocess/Cargo.toml b/librashader-preprocess/Cargo.toml index 62222b5..721c772 100644 --- a/librashader-preprocess/Cargo.toml +++ b/librashader-preprocess/Cargo.toml @@ -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] diff --git a/librashader-preprocess/src/lib.rs b/librashader-preprocess/src/lib.rs index da41330..b257ed3 100644 --- a/librashader-preprocess/src/lib.rs +++ b/librashader-preprocess/src/lib.rs @@ -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, /// The list of shader parameters found in the shader source. - pub parameters: FxHashMap, + pub parameters: FastHashMap, /// The image format the shader expects. pub format: ImageFormat, @@ -82,7 +82,7 @@ pub(crate) fn load_shader_source(path: impl AsRef) -> Result FxHashMap { - let mut map = FxHashMap::default(); + pub fn to_hashmap(mut self) -> FastHashMap { + 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) { +pub(crate) fn apply_context(path: &mut PathBuf, context: &FastHashMap) { use std::ffi::{OsStr, OsString}; static WILDCARD_REGEX: Lazy = Lazy::new(|| Regex::new("\\$([A-Z-_]+)\\$").unwrap()); @@ -409,7 +409,7 @@ pub(crate) fn apply_context(path: &mut PathBuf, context: &FxHashMap) { +pub(crate) fn apply_context(path: &mut PathBuf, context: &FastHashMap) { use os_str_bytes::RawOsStr; static WILDCARD_REGEX: Lazy = Lazy::new(|| Regex::new("\\$([A-Z-_]+)\\$").unwrap()); if context.is_empty() { diff --git a/librashader-presets/src/parse/value.rs b/librashader-presets/src/parse/value.rs index 0a0b4ff..0ee4182 100644 --- a/librashader-presets/src/parse/value.rs +++ b/librashader-presets/src/parse/value.rs @@ -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, root_path: impl AsRef, - context: &FxHashMap, + context: &FastHashMap, ) -> Result, ParsePresetError> { let root_path = root_path.as_ref(); @@ -238,7 +238,7 @@ pub(crate) fn parse_preset( pub fn parse_values( mut tokens: Vec, root_path: impl AsRef, - context: FxHashMap, + context: FastHashMap, ) -> Result, ParsePresetError> { let mut root_path = root_path.as_ref().to_path_buf(); if root_path.is_relative() { diff --git a/librashader-reflect/Cargo.toml b/librashader-reflect/Cargo.toml index 9758dfd..f4d3e6b 100644 --- a/librashader-reflect/Cargo.toml +++ b/librashader-reflect/Cargo.toml @@ -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" diff --git a/librashader-reflect/src/reflect/presets.rs b/librashader-reflect/src/reflect/presets.rs index 95b685d..2009b7b 100644 --- a/librashader-reflect/src/reflect/presets.rs +++ b/librashader-reflect/src/reflect/presets.rs @@ -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, E: From, { - let mut uniform_semantics: FxHashMap = Default::default(); - let mut texture_semantics: FxHashMap> = Default::default(); + let mut uniform_semantics: FastHashMap = Default::default(); + let mut texture_semantics: FastHashMap> = 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, - texture_semantics: &mut FxHashMap>, + uniform_semantics: &mut FastHashMap, + texture_semantics: &mut FastHashMap>, 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, - texture_semantics: &mut FxHashMap>, + uniform_semantics: &mut FastHashMap, + texture_semantics: &mut FastHashMap>, ) { for (index, texture) in textures.iter().enumerate() { texture_semantics.insert( diff --git a/librashader-reflect/src/reflect/semantics.rs b/librashader-reflect/src/reflect/semantics.rs index 18bffa9..894c270 100644 --- a/librashader-reflect/src/reflect/semantics.rs +++ b/librashader-reflect/src/reflect/semantics.rs @@ -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>; } -impl TextureSemanticMap for FxHashMap { +impl TextureSemanticMap for FastHashMap { fn get_texture_semantic(&self, name: &str) -> Option> { match self.get(name) { None => { @@ -353,7 +353,7 @@ impl TextureSemanticMap for FxHashMap { } } -impl TextureSemanticMap for FxHashMap> { +impl TextureSemanticMap for FastHashMap> { fn get_texture_semantic(&self, name: &str) -> Option> { match self.get(name) { None => { @@ -390,7 +390,7 @@ pub trait UniqueSemanticMap { fn get_unique_semantic(&self, name: &str) -> Option>; } -impl UniqueSemanticMap for FxHashMap { +impl UniqueSemanticMap for FastHashMap { fn get_unique_semantic(&self, name: &str) -> Option> { 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, + pub uniform_semantics: FastHashMap, /// A map of texture names to filter chain semantics. - pub texture_semantics: FxHashMap>, + pub texture_semantics: FastHashMap>, } /// The binding of a uniform after the shader has been linked. @@ -483,11 +483,11 @@ impl From> for UniformBinding { #[derive(Debug, Default)] pub struct BindingMeta { /// A map of parameter names to uniform binding metadata. - pub parameter_meta: FxHashMap, + pub parameter_meta: FastHashMap, /// A map of unique semantics to uniform binding metadata. - pub unique_meta: FxHashMap, + pub unique_meta: FastHashMap, /// A map of texture semantics to texture binding points. - pub texture_meta: FxHashMap, TextureBinding>, + pub texture_meta: FastHashMap, TextureBinding>, /// A map of texture semantics to texture size uniform binding metadata. - pub texture_size_meta: FxHashMap, TextureSizeMeta>, + pub texture_size_meta: FastHashMap, TextureSizeMeta>, } diff --git a/librashader-runtime-d3d11/Cargo.toml b/librashader-runtime-d3d11/Cargo.toml index ad5e9fc..eda6119 100644 --- a/librashader-runtime-d3d11/Cargo.toml +++ b/librashader-runtime-d3d11/Cargo.toml @@ -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" diff --git a/librashader-runtime-d3d11/src/filter_chain.rs b/librashader-runtime-d3d11/src/filter_chain.rs index 554d9a8..845944f 100644 --- a/librashader-runtime-d3d11/src/filter_chain.rs +++ b/librashader-runtime-d3d11/src/filter_chain.rs @@ -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, + pub(crate) parameters: FastHashMap, } /// 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, + pub(crate) luts: FastHashMap, pub samplers: SamplerSet, pub output_textures: Box<[Option]>, pub feedback_textures: Box<[Option]>, @@ -355,8 +355,8 @@ impl FilterChainD3D11 { device: &ID3D11Device, context: &ID3D11DeviceContext, textures: &[TextureConfig], - ) -> error::Result> { - let mut luts = FxHashMap::default(); + ) -> error::Result> { + let mut luts = FastHashMap::default(); let images = textures .par_iter() .map(|texture| Image::load(&texture.path, UVDirection::TopLeft)) diff --git a/librashader-runtime-d3d11/src/filter_pass.rs b/librashader-runtime-d3d11/src/filter_pass.rs index b96b919..d08465b 100644 --- a/librashader-runtime-d3d11/src/filter_pass.rs +++ b/librashader-runtime-d3d11/src/filter_pass.rs @@ -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, + pub uniform_bindings: FastHashMap, pub uniform_storage: UniformStorage, pub uniform_buffer: Option, diff --git a/librashader-runtime-d3d11/src/samplers.rs b/librashader-runtime-d3d11/src/samplers.rs index 4b6bec5..e1c18b4 100644 --- a/librashader-runtime-d3d11/src/samplers.rs +++ b/librashader-runtime-d3d11/src/samplers.rs @@ -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 { - let mut samplers = FxHashMap::default(); + let mut samplers = FastHashMap::default(); let wrap_modes = &[ WrapMode::ClampToBorder, WrapMode::ClampToEdge, diff --git a/librashader-runtime-d3d12/Cargo.toml b/librashader-runtime-d3d12/Cargo.toml index 9462524..f3fd2e6 100644 --- a/librashader-runtime-d3d12/Cargo.toml +++ b/librashader-runtime-d3d12/Cargo.toml @@ -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" diff --git a/librashader-runtime-d3d12/src/filter_chain.rs b/librashader-runtime-d3d12/src/filter_chain.rs index 346b1ca..d25d2fa 100644 --- a/librashader-runtime-d3d12/src/filter_chain.rs +++ b/librashader-runtime-d3d12/src/filter_chain.rs @@ -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, + pub(crate) parameters: FastHashMap, } /// A Direct3D 12 filter chain. @@ -89,7 +89,7 @@ pub(crate) struct FilterCommon { pub history_textures: Box<[Option]>, pub config: FilterMutable, // pub disable_mipmaps: bool, - pub luts: FxHashMap, + pub luts: FastHashMap, pub mipmap_gen: D3D12MipmapGen, pub root_signature: D3D12RootSignature, pub draw_quad: DrawQuad, @@ -371,11 +371,11 @@ impl FilterChainD3D12 { mipmap_heap: &mut D3D12DescriptorHeap, gc: &mut FrameResiduals, textures: &[TextureConfig], - ) -> error::Result> { + ) -> error::Result> { // 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)) diff --git a/librashader-runtime-d3d12/src/filter_pass.rs b/librashader-runtime-d3d12/src/filter_pass.rs index a4aa0f7..e360633 100644 --- a/librashader-runtime-d3d12/src/filter_pass.rs +++ b/librashader-runtime-d3d12/src/filter_pass.rs @@ -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, + pub(crate) uniform_bindings: FastHashMap, pub uniform_storage: UniformStorage, RawD3D12Buffer, RawD3D12Buffer>, pub(crate) texture_heap: [D3D12DescriptorHeapSlot; 16], diff --git a/librashader-runtime-d3d12/src/samplers.rs b/librashader-runtime-d3d12/src/samplers.rs index 9b0215e..112b383 100644 --- a/librashader-runtime-d3d12/src/samplers.rs +++ b/librashader-runtime-d3d12/src/samplers.rs @@ -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>, + samplers: FastHashMap<(WrapMode, FilterMode), D3D12DescriptorHeapSlot>, _heap: D3D12DescriptorHeap, } @@ -25,7 +25,7 @@ impl SamplerSet { unsafe { self.samplers.get(&(wrap, filter)).unwrap_unchecked() } } pub fn new(device: &ID3D12Device) -> error::Result { - let mut samplers = FxHashMap::default(); + let mut samplers = FastHashMap::default(); let wrap_modes = &[ WrapMode::ClampToBorder, WrapMode::ClampToEdge, diff --git a/librashader-runtime-gl/Cargo.toml b/librashader-runtime-gl/Cargo.toml index 8112e01..5133d63 100644 --- a/librashader-runtime-gl/Cargo.toml +++ b/librashader-runtime-gl/Cargo.toml @@ -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" diff --git a/librashader-runtime-gl/src/filter_chain/filter_impl.rs b/librashader-runtime-gl/src/filter_chain/filter_impl.rs index 6a09f9e..355fc8c 100644 --- a/librashader-runtime-gl/src/filter_chain/filter_impl.rs +++ b/librashader-runtime-gl/src/filter_chain/filter_impl.rs @@ -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 { pub(crate) struct FilterCommon { // semantics: ReflectSemantics, pub config: FilterMutable, - pub luts: FxHashMap, + pub luts: FastHashMap, 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, + pub(crate) parameters: FastHashMap, } impl FilterChainImpl { diff --git a/librashader-runtime-gl/src/filter_chain/parameters.rs b/librashader-runtime-gl/src/filter_chain/parameters.rs index 670aee6..cc69243 100644 --- a/librashader-runtime-gl/src/filter_chain/parameters.rs +++ b/librashader-runtime-gl/src/filter_chain/parameters.rs @@ -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 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 { + fn enumerate_parameters(&self) -> ::librashader_common::map::halfbrown::Iter { self.filter.as_ref().enumerate_parameters() } @@ -54,7 +53,7 @@ impl FilterChainParameters for FilterChainImpl { self.common.config.passes_enabled = count } - fn enumerate_parameters(&self) -> Iter { + fn enumerate_parameters(&self) -> ::librashader_common::map::halfbrown::Iter { self.common.config.parameters.iter() } diff --git a/librashader-runtime-gl/src/filter_pass.rs b/librashader-runtime-gl/src/filter_pass.rs index cd4555f..def1c1e 100644 --- a/librashader-runtime-gl/src/filter_pass.rs +++ b/librashader-runtime-gl/src/filter_pass.rs @@ -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 { pub ubo_location: UniformLocation, pub ubo_ring: Option, pub(crate) uniform_storage: GlUniformStorage, - pub uniform_bindings: FxHashMap, + pub uniform_bindings: FastHashMap, pub source: ShaderSource, pub config: ShaderPassConfig, } diff --git a/librashader-runtime-gl/src/gl/gl3/lut_load.rs b/librashader-runtime-gl/src/gl/gl3/lut_load.rs index 4eb5e03..8d64e9d 100644 --- a/librashader-runtime-gl/src/gl/gl3/lut_load.rs +++ b/librashader-runtime-gl/src/gl/gl3/lut_load.rs @@ -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> { - let mut luts = FxHashMap::default(); + fn load_luts(textures: &[TextureConfig]) -> Result> { + let mut luts = FastHashMap::default(); let pixel_unpack = unsafe { let mut binding = 0; gl::GetIntegerv(gl::PIXEL_UNPACK_BUFFER_BINDING, &mut binding); diff --git a/librashader-runtime-gl/src/gl/gl46/lut_load.rs b/librashader-runtime-gl/src/gl/gl46/lut_load.rs index 41cc5d2..f022613 100644 --- a/librashader-runtime-gl/src/gl/gl46/lut_load.rs +++ b/librashader-runtime-gl/src/gl/gl46/lut_load.rs @@ -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> { - let mut luts = FxHashMap::default(); + fn load_luts(textures: &[TextureConfig]) -> Result> { + let mut luts = FastHashMap::default(); let pixel_unpack = unsafe { let mut binding = 0; gl::GetIntegerv(gl::PIXEL_UNPACK_BUFFER_BINDING, &mut binding); diff --git a/librashader-runtime-gl/src/gl/mod.rs b/librashader-runtime-gl/src/gl/mod.rs index b71bb42..edcf93c 100644 --- a/librashader-runtime-gl/src/gl/mod.rs +++ b/librashader-runtime-gl/src/gl/mod.rs @@ -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>; + fn load_luts(textures: &[TextureConfig]) -> Result>; } pub(crate) trait CompileProgram { diff --git a/librashader-runtime-gl/src/samplers.rs b/librashader-runtime-gl/src/samplers.rs index cc51d2c..f564ba5 100644 --- a/librashader-runtime-gl/src/samplers.rs +++ b/librashader-runtime-gl/src/samplers.rs @@ -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, diff --git a/librashader-runtime-mtl/Cargo.toml b/librashader-runtime-mtl/Cargo.toml index a6f2724..9661269 100644 --- a/librashader-runtime-mtl/Cargo.toml +++ b/librashader-runtime-mtl/Cargo.toml @@ -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"] } diff --git a/librashader-runtime-mtl/src/filter_chain.rs b/librashader-runtime-mtl/src/filter_chain.rs index a60ba59..c115482 100644 --- a/librashader-runtime-mtl/src/filter_chain.rs +++ b/librashader-runtime-mtl/src/filter_chain.rs @@ -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, + pub(crate) parameters: FastHashMap, } pub(crate) struct FilterCommon { pub output_textures: Box<[Option]>, pub feedback_textures: Box<[Option]>, pub history_textures: Box<[Option]>, - pub luts: FxHashMap, + pub luts: FastHashMap, pub samplers: SamplerSet, pub config: FilterMutable, pub internal_frame_count: i32, @@ -122,8 +122,8 @@ impl FilterChainMetal { device: &ProtocolObject, cmd: &ProtocolObject, textures: &[TextureConfig], - ) -> error::Result> { - let mut luts = FxHashMap::default(); + ) -> error::Result> { + let mut luts = FastHashMap::default(); let mipmapper = cmd .blitCommandEncoder() diff --git a/librashader-runtime-mtl/src/filter_pass.rs b/librashader-runtime-mtl/src/filter_pass.rs index 3d6f2c8..cd4880f 100644 --- a/librashader-runtime-mtl/src/filter_pass.rs +++ b/librashader-runtime-mtl/src/filter_pass.rs @@ -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 { @@ -53,7 +53,7 @@ pub struct FilterPass { pub reflection: ShaderReflection, pub(crate) uniform_storage: UniformStorage, MetalBuffer, MetalBuffer>, - pub uniform_bindings: FxHashMap, + pub uniform_bindings: FastHashMap, pub source: ShaderSource, pub config: ShaderPassConfig, pub graphics_pipeline: MetalGraphicsPipeline, diff --git a/librashader-runtime-mtl/src/samplers.rs b/librashader-runtime-mtl/src/samplers.rs index d0cff8e..10ec165 100644 --- a/librashader-runtime-mtl/src/samplers.rs +++ b/librashader-runtime-mtl/src/samplers.rs @@ -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>>, + FastHashMap<(WrapMode, FilterMode, FilterMode), Id>>, } impl SamplerSet { @@ -37,7 +37,7 @@ impl SamplerSet { } pub fn new(device: &ProtocolObject) -> Result { - let mut samplers = FxHashMap::default(); + let mut samplers = FastHashMap::default(); let wrap_modes = &[ WrapMode::ClampToBorder, WrapMode::ClampToEdge, diff --git a/librashader-runtime-vk/Cargo.toml b/librashader-runtime-vk/Cargo.toml index 77a07ed..324211f 100644 --- a/librashader-runtime-vk/Cargo.toml +++ b/librashader-runtime-vk/Cargo.toml @@ -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"] } diff --git a/librashader-runtime-vk/src/filter_chain.rs b/librashader-runtime-vk/src/filter_chain.rs index 75178d9..6b267f9 100644 --- a/librashader-runtime-vk/src/filter_chain.rs +++ b/librashader-runtime-vk/src/filter_chain.rs @@ -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, + pub(crate) parameters: FastHashMap, } pub(crate) struct FilterCommon { - pub(crate) luts: FxHashMap, + pub(crate) luts: FastHashMap, pub samplers: SamplerSet, pub(crate) draw_quad: DrawQuad, pub output_textures: Box<[Option]>, @@ -482,8 +482,8 @@ impl FilterChainVulkan { vulkan: &VulkanObjects, command_buffer: vk::CommandBuffer, textures: &[TextureConfig], - ) -> error::Result> { - let mut luts = FxHashMap::default(); + ) -> error::Result> { + let mut luts = FastHashMap::default(); let images = textures .par_iter() .map(|texture| Image::load(&texture.path, UVDirection::TopLeft)) diff --git a/librashader-runtime-vk/src/filter_pass.rs b/librashader-runtime-vk/src/filter_pass.rs index 1577b36..4c5d3d1 100644 --- a/librashader-runtime-vk/src/filter_pass.rs +++ b/librashader-runtime-vk/src/filter_pass.rs @@ -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>, pub(crate) uniform_storage: UniformStorage, RawVulkanBuffer>, - pub uniform_bindings: FxHashMap, + pub uniform_bindings: FastHashMap, pub source: ShaderSource, pub config: ShaderPassConfig, pub graphics_pipeline: VulkanGraphicsPipeline, diff --git a/librashader-runtime-vk/src/samplers.rs b/librashader-runtime-vk/src/samplers.rs index 8f93dbb..76bbe9e 100644 --- a/librashader-runtime-vk/src/samplers.rs +++ b/librashader-runtime-vk/src/samplers.rs @@ -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) -> error::Result { - let mut samplers = FxHashMap::default(); + let mut samplers = FastHashMap::default(); let wrap_modes = &[ WrapMode::ClampToBorder, WrapMode::ClampToEdge, diff --git a/librashader-runtime-wgpu/Cargo.toml b/librashader-runtime-wgpu/Cargo.toml index 3224036..7f1ea35 100644 --- a/librashader-runtime-wgpu/Cargo.toml +++ b/librashader-runtime-wgpu/Cargo.toml @@ -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"] } diff --git a/librashader-runtime-wgpu/src/filter_chain.rs b/librashader-runtime-wgpu/src/filter_chain.rs index 3856b43..37559bf 100644 --- a/librashader-runtime-wgpu/src/filter_chain.rs +++ b/librashader-runtime-wgpu/src/filter_chain.rs @@ -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, + pub(crate) parameters: FastHashMap, } pub(crate) struct FilterCommon { pub output_textures: Box<[Option]>, pub feedback_textures: Box<[Option]>, pub history_textures: Box<[Option]>, - pub luts: FxHashMap, + pub luts: FastHashMap, 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> { - let mut luts = FxHashMap::default(); + ) -> error::Result> { + let mut luts = FastHashMap::default(); #[cfg(not(target_arch = "wasm32"))] let images_iter = textures.par_iter(); diff --git a/librashader-runtime-wgpu/src/filter_pass.rs b/librashader-runtime-wgpu/src/filter_pass.rs index 697b63a..7a725f1 100644 --- a/librashader-runtime-wgpu/src/filter_pass.rs +++ b/librashader-runtime-wgpu/src/filter_pass.rs @@ -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, WgpuStagedBuffer, WgpuStagedBuffer>, - pub uniform_bindings: FxHashMap, + pub uniform_bindings: FastHashMap, pub source: ShaderSource, pub config: ShaderPassConfig, pub graphics_pipeline: WgpuGraphicsPipeline, @@ -48,8 +48,8 @@ impl BindSemantics, WgpuStagedBuffer, WgpuStagedBuff type InputTexture = InputImage; type SamplerSet = SamplerSet; type DescriptorSet<'a> = ( - &'a mut FxHashMap>, - &'a mut FxHashMap>, + &'a mut FastHashMap>, + &'a mut FastHashMap>, ); type DeviceContext = Arc; type UniformOffset = MemberOffset; @@ -97,8 +97,8 @@ impl FilterPass { output: &RenderTarget, 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, original: &InputImage, source: &InputImage, - main_heap: &'a mut FxHashMap>, - sampler_heap: &'a mut FxHashMap>, + main_heap: &'a mut FastHashMap>, + sampler_heap: &'a mut FastHashMap>, ) { Self::bind_semantics( &self.device, diff --git a/librashader-runtime-wgpu/src/mipmap.rs b/librashader-runtime-wgpu/src/mipmap.rs index af0b23d..8963054 100644 --- a/librashader-runtime-wgpu/src/mipmap.rs +++ b/librashader-runtime-wgpu/src/mipmap.rs @@ -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, shader: wgpu::ShaderModule, - pipeline_cache: FxHashMap, + pipeline_cache: FastHashMap, } impl MipmapGen { diff --git a/librashader-runtime-wgpu/src/samplers.rs b/librashader-runtime-wgpu/src/samplers.rs index ed0eccb..1fe54d7 100644 --- a/librashader-runtime-wgpu/src/samplers.rs +++ b/librashader-runtime-wgpu/src/samplers.rs @@ -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>, + samplers: FastHashMap<(WrapMode, FilterMode, FilterMode), Arc>, } 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, diff --git a/librashader-runtime/Cargo.toml b/librashader-runtime/Cargo.toml index 0875519..8ad16a9 100644 --- a/librashader-runtime/Cargo.toml +++ b/librashader-runtime/Cargo.toml @@ -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 = [ diff --git a/librashader-runtime/src/binding.rs b/librashader-runtime/src/binding.rs index 672b3c0..be53e94 100644 --- a/librashader-runtime/src/binding.rs +++ b/librashader-runtime/src/binding.rs @@ -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, - texture_meta: &HashMap, TextureBinding, impl BuildHasher>, + uniform_bindings: &FastHashMap, + texture_meta: &FastHashMap, TextureBinding>, pass_outputs: impl Iterator>>, pass_feedback: impl Iterator>>, original_history: impl Iterator>>, lookup_textures: impl Iterator)>, - parameter_defaults: &HashMap, - runtime_parameters: &HashMap, + parameter_defaults: &FastHashMap, + runtime_parameters: &FastHashMap, ) { // Bind MVP if let Some(offset) = uniform_bindings.get(&UniqueSemantics::MVP.into()) { @@ -328,7 +326,7 @@ pub trait BindingUtil { fn create_binding_map( &self, f: impl Fn(&dyn UniformMeta) -> T, - ) -> FxHashMap; + ) -> FastHashMap; /// Calculate the number of required images for history. fn calculate_required_history<'a>(pass_meta: impl Iterator) -> usize @@ -340,8 +338,8 @@ impl BindingUtil for BindingMeta { fn create_binding_map( &self, f: impl Fn(&dyn UniformMeta) -> T, - ) -> FxHashMap { - let mut uniform_bindings = FxHashMap::default(); + ) -> FastHashMap { + let mut uniform_bindings = FastHashMap::default(); for param in self.parameter_meta.values() { uniform_bindings.insert(UniformBinding::Parameter(param.id.clone()), f(param)); } diff --git a/librashader-runtime/src/parameters.rs b/librashader-runtime/src/parameters.rs index 801c7d4..e1d93dc 100644 --- a/librashader-runtime/src/parameters.rs +++ b/librashader-runtime/src/parameters.rs @@ -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; + fn enumerate_parameters<'a>(&'a self) -> ::librashader_common::map::halfbrown::Iter; /// Get the value of the given parameter if present. fn get_parameter(&self, parameter: &str) -> Option; @@ -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 { + fn enumerate_parameters<'a>(&'a self) -> ::librashader_common::map::halfbrown::Iter { self.common.config.parameters.iter() } diff --git a/librashader/src/lib.rs b/librashader/src/lib.rs index a5a3d8b..205c176 100644 --- a/librashader/src/lib.rs +++ b/librashader/src/lib.rs @@ -64,7 +64,9 @@ pub mod presets { let iters: Result>, 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())