From 6fbc4b3075a655be62962fccb71259975702a9c3 Mon Sep 17 00:00:00 2001 From: chyyran Date: Wed, 14 Feb 2024 19:22:25 -0500 Subject: [PATCH] fmt: cargo fmt --- librashader-cache/src/cache.rs | 25 +++++++++++----- librashader-cache/src/compilation.rs | 12 ++++++-- librashader-capi/src/ctypes.rs | 29 +++++++++++++++---- librashader-capi/src/error.rs | 2 +- librashader-capi/src/runtime/mod.rs | 19 ++++++++++-- .../src/runtime/mtl/filter_chain.rs | 9 ++---- librashader-common/src/map.rs | 6 ++-- librashader-preprocess/src/lib.rs | 2 +- librashader-presets/src/context.rs | 2 +- librashader-presets/src/parse/value.rs | 2 +- librashader-reflect/src/reflect/presets.rs | 2 +- librashader-runtime-d3d11/src/filter_chain.rs | 4 +-- librashader-runtime-d3d11/src/filter_pass.rs | 2 +- librashader-runtime-d3d11/src/samplers.rs | 2 +- librashader-runtime-d3d12/src/filter_chain.rs | 4 +-- librashader-runtime-d3d12/src/filter_pass.rs | 2 +- librashader-runtime-d3d12/src/samplers.rs | 2 +- .../src/filter_chain/filter_impl.rs | 4 +-- librashader-runtime-gl/src/filter_pass.rs | 2 +- .../src/gl/gl3/draw_quad.rs | 2 +- librashader-runtime-gl/src/gl/gl3/lut_load.rs | 2 +- .../src/gl/gl46/draw_quad.rs | 2 +- .../src/gl/gl46/lut_load.rs | 2 +- librashader-runtime-gl/src/gl/mod.rs | 2 +- librashader-runtime-gl/src/samplers.rs | 2 +- librashader-runtime-mtl/src/filter_chain.rs | 2 +- librashader-runtime-mtl/src/filter_pass.rs | 2 +- .../src/graphics_pipeline.rs | 2 +- librashader-runtime-mtl/src/samplers.rs | 2 +- librashader-runtime-vk/src/filter_chain.rs | 4 +-- librashader-runtime-vk/src/filter_pass.rs | 2 +- librashader-runtime-vk/src/samplers.rs | 2 +- librashader-runtime-wgpu/src/filter_chain.rs | 4 +-- librashader-runtime-wgpu/src/filter_pass.rs | 2 +- librashader-runtime-wgpu/src/samplers.rs | 2 +- librashader-runtime/src/binding.rs | 2 +- librashader-runtime/src/parameters.rs | 8 +++-- librashader/src/lib.rs | 16 ++++++---- 38 files changed, 124 insertions(+), 70 deletions(-) diff --git a/librashader-cache/src/cache.rs b/librashader-cache/src/cache.rs index 72b7cff..091c11a 100644 --- a/librashader-cache/src/cache.rs +++ b/librashader-cache/src/cache.rs @@ -6,7 +6,7 @@ pub(crate) mod internal { use std::error::Error; use std::path::PathBuf; - use persy::{Config, Persy, ByteVec, ValueMode}; + use persy::{ByteVec, Config, Persy, ValueMode}; pub(crate) fn get_cache_dir() -> Result> { let cache_dir = if let Some(cache_dir) = @@ -45,11 +45,15 @@ pub(crate) mod internal { pub(crate) fn get_cache() -> Result> { let cache_dir = get_cache_dir()?; - let conn = Persy::open_or_create_with(&cache_dir.join("librashader.db.1"), Config::new(), |persy| { - let tx = persy.begin()?; - tx.commit()?; - Ok(()) - })?; + let conn = Persy::open_or_create_with( + &cache_dir.join("librashader.db.1"), + Config::new(), + |persy| { + let tx = persy.begin()?; + tx.commit()?; + Ok(()) + }, + )?; Ok(conn) } @@ -59,14 +63,19 @@ pub(crate) mod internal { key: &[u8], ) -> Result>, Box> { if !conn.exists_index(index)? { - return Ok(None); + return Ok(None); } let value = conn.get::<_, ByteVec>(index, &ByteVec::from(key))?.next(); Ok(value.map(|v| v.to_vec())) } - pub(crate) fn set_blob(conn: &Persy, index: &str, key: &[u8], value: &[u8]) -> Result<(), Box> { + pub(crate) fn set_blob( + conn: &Persy, + index: &str, + key: &[u8], + value: &[u8], + ) -> Result<(), Box> { let mut tx = conn.begin()?; if !tx.exists_index(index)? { tx.create_index::(index, ValueMode::Replace)?; diff --git a/librashader-cache/src/compilation.rs b/librashader-cache/src/compilation.rs index 42e363a..6e1191c 100644 --- a/librashader-cache/src/compilation.rs +++ b/librashader-cache/src/compilation.rs @@ -14,7 +14,9 @@ pub struct CachedCompilation { compilation: T, } -impl ShaderReflectObject for CachedCompilation { type Compiler = T::Compiler; } +impl ShaderReflectObject for CachedCompilation { + type Compiler = T::Compiler; +} impl serde::Deserialize<'de> + serde::Serialize + Clone> ShaderInputCompiler> for Glslang @@ -39,7 +41,9 @@ where }; let compilation = 'cached: { - if let Ok(Some(cached)) = crate::cache::internal::get_blob(&cache, "spirv", key.as_bytes()) { + if let Ok(Some(cached)) = + crate::cache::internal::get_blob(&cache, "spirv", key.as_bytes()) + { let decoded = bincode::serde::decode_from_slice(&cached, bincode::config::standard()) .map(|(compilation, _)| CachedCompilation { compilation }) @@ -58,7 +62,9 @@ where if let Ok(updated) = bincode::serde::encode_to_vec(&compilation.compilation, bincode::config::standard()) { - let Ok(()) = crate::cache::internal::set_blob(&cache, "spirv", key.as_bytes(), &updated) else { + let Ok(()) = + crate::cache::internal::set_blob(&cache, "spirv", key.as_bytes(), &updated) + else { return Ok(compilation); }; } diff --git a/librashader-capi/src/ctypes.rs b/librashader-capi/src/ctypes.rs index ea3522c..9bd7336 100644 --- a/librashader-capi/src/ctypes.rs +++ b/librashader-capi/src/ctypes.rs @@ -64,18 +64,30 @@ use librashader::runtime::gl::FilterChain as FilterChainGL; pub type libra_gl_filter_chain_t = Option>; /// A handle to a Direct3D 11 filter chain. -#[cfg(any(feature = "__cbindgen_internal", all(target_os = "windows", feature = "runtime-d3d11")))] +#[cfg(any( + feature = "__cbindgen_internal", + all(target_os = "windows", feature = "runtime-d3d11") +))] use librashader::runtime::d3d11::FilterChain as FilterChainD3D11; /// A handle to a Direct3D 11 filter chain. #[doc(cfg(all(target_os = "windows", feature = "runtime-d3d11")))] -#[cfg(any(feature = "__cbindgen_internal", all(target_os = "windows", feature = "runtime-d3d11")))] +#[cfg(any( + feature = "__cbindgen_internal", + all(target_os = "windows", feature = "runtime-d3d11") +))] pub type libra_d3d11_filter_chain_t = Option>; -#[cfg(any(feature = "__cbindgen_internal", all(target_os = "windows", feature = "runtime-d3d12")))] +#[cfg(any( + feature = "__cbindgen_internal", + all(target_os = "windows", feature = "runtime-d3d12") +))] use librashader::runtime::d3d12::FilterChain as FilterChainD3D12; /// A handle to a Direct3D 12 filter chain. -#[cfg(any(feature = "__cbindgen_internal", all(target_os = "windows", feature = "runtime-d3d12")))] +#[cfg(any( + feature = "__cbindgen_internal", + all(target_os = "windows", feature = "runtime-d3d12") +))] pub type libra_d3d12_filter_chain_t = Option>; #[cfg(feature = "runtime-vulkan")] @@ -88,7 +100,14 @@ pub type libra_vk_filter_chain_t = Option>; #[cfg(all(target_os = "macos", feature = "runtime-metal"))] use librashader::runtime::mtl::FilterChain as FilterChainMetal; #[doc(cfg(all(target_vendor = "apple", feature = "runtime-metal")))] -#[cfg(any(feature = "__cbindgen_internal", all(target_vendor = "apple", feature = "runtime-metal", feature = "__cbindgen_internal_objc")))] +#[cfg(any( + feature = "__cbindgen_internal", + all( + target_vendor = "apple", + feature = "runtime-metal", + feature = "__cbindgen_internal_objc" + ) +))] pub type libra_mtl_filter_chain_t = Option>; /// Defines the output viewport for a rendered frame. diff --git a/librashader-capi/src/error.rs b/librashader-capi/src/error.rs index 29d9e24..3300eba 100644 --- a/librashader-capi/src/error.rs +++ b/librashader-capi/src/error.rs @@ -192,7 +192,7 @@ impl LibrashaderError { #[cfg(feature = "runtime-vulkan")] LibrashaderError::VulkanFilterError(_) => LIBRA_ERRNO::RUNTIME_ERROR, #[cfg(all(target_vendor = "apple", feature = "runtime-metal"))] - LibrashaderError::MetalFilterError(_) => LIBRA_ERRNO::RUNTIME_ERROR + LibrashaderError::MetalFilterError(_) => LIBRA_ERRNO::RUNTIME_ERROR, } } pub(crate) const fn ok() -> libra_error_t { diff --git a/librashader-capi/src/runtime/mod.rs b/librashader-capi/src/runtime/mod.rs index 685c439..2eb2edc 100644 --- a/librashader-capi/src/runtime/mod.rs +++ b/librashader-capi/src/runtime/mod.rs @@ -8,13 +8,26 @@ pub mod gl; pub mod vk; #[doc(cfg(all(target_os = "windows", feature = "runtime-d3d11")))] -#[cfg(any(feature = "__cbindgen_internal", all(target_os = "windows", feature = "runtime-d3d11")))] +#[cfg(any( + feature = "__cbindgen_internal", + all(target_os = "windows", feature = "runtime-d3d11") +))] pub mod d3d11; #[doc(cfg(all(target_os = "windows", feature = "runtime-d3d12")))] -#[cfg(any(feature = "__cbindgen_internal", all(target_os = "windows", feature = "runtime-d3d12")))] +#[cfg(any( + feature = "__cbindgen_internal", + all(target_os = "windows", feature = "runtime-d3d12") +))] pub mod d3d12; #[doc(cfg(all(target_vendor = "apple", feature = "runtime-metal")))] -#[cfg(any(feature = "__cbindgen_internal", all(target_vendor = "apple", feature = "runtime-metal", feature = "__cbindgen_internal_objc")))] +#[cfg(any( + feature = "__cbindgen_internal", + all( + target_vendor = "apple", + feature = "runtime-metal", + feature = "__cbindgen_internal_objc" + ) +))] pub mod mtl; diff --git a/librashader-capi/src/runtime/mtl/filter_chain.rs b/librashader-capi/src/runtime/mtl/filter_chain.rs index 01725c0..e6bf4ee 100644 --- a/librashader-capi/src/runtime/mtl/filter_chain.rs +++ b/librashader-capi/src/runtime/mtl/filter_chain.rs @@ -1,13 +1,11 @@ use crate::ctypes::{ - config_struct, libra_shader_preset_t, libra_viewport_t, libra_mtl_filter_chain_t, FromUninit, + config_struct, libra_mtl_filter_chain_t, libra_shader_preset_t, libra_viewport_t, FromUninit, }; use crate::error::{assert_non_null, assert_some_ptr, LibrashaderError}; use crate::ffi::extern_fn; -use librashader::runtime::mtl::{ - FilterChain, FilterChainOptions, FrameOptions, -}; +use librashader::runtime::mtl::{FilterChain, FilterChainOptions, FrameOptions}; +use std::ffi::c_char; use std::ffi::CStr; -use std::ffi::{c_char}; use std::mem::MaybeUninit; use std::ptr::NonNull; use std::slice; @@ -29,7 +27,6 @@ pub type PMTLCommandBuffer = *const ProtocolObject; /// An alias to a `id` protocol object pointer. pub type PMTLTexture = *const ProtocolObject; - /// Options for each Metal shader frame. #[repr(C)] #[derive(Default, Debug, Clone)] diff --git a/librashader-common/src/map.rs b/librashader-common/src/map.rs index 6aabaed..9179a10 100644 --- a/librashader-common/src/map.rs +++ b/librashader-common/src/map.rs @@ -1,5 +1,5 @@ /// Fast optimized hash map type for small sets. -pub type FastHashMap = halfbrown::SizedHashMap, 32>; +pub type FastHashMap = + halfbrown::SizedHashMap, 32>; -pub use halfbrown; \ No newline at end of file +pub use halfbrown; diff --git a/librashader-preprocess/src/lib.rs b/librashader-preprocess/src/lib.rs index b257ed3..45ca4c9 100644 --- a/librashader-preprocess/src/lib.rs +++ b/librashader-preprocess/src/lib.rs @@ -15,8 +15,8 @@ mod stage; use crate::include::read_source; pub use error::*; -use librashader_common::ImageFormat; use librashader_common::map::FastHashMap; +use librashader_common::ImageFormat; use std::path::Path; /// The source file for a single shader pass. diff --git a/librashader-presets/src/context.rs b/librashader-presets/src/context.rs index e7d25d3..1d35875 100644 --- a/librashader-presets/src/context.rs +++ b/librashader-presets/src/context.rs @@ -4,13 +4,13 @@ //! //! Implements wildcard replacement of shader paths specified in //! [RetroArch#15023](https://github.com/libretro/RetroArch/pull/15023). +use librashader_common::map::FastHashMap; use once_cell::sync::Lazy; use regex::bytes::Regex; 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)] diff --git a/librashader-presets/src/parse/value.rs b/librashader-presets/src/parse/value.rs index 0ee4182..333fe4e 100644 --- a/librashader-presets/src/parse/value.rs +++ b/librashader-presets/src/parse/value.rs @@ -10,12 +10,12 @@ use nom::IResult; use num_traits::cast::ToPrimitive; use crate::parse::token::do_lex; +use librashader_common::map::FastHashMap; use librashader_common::{FilterMode, WrapMode}; 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; diff --git a/librashader-reflect/src/reflect/presets.rs b/librashader-reflect/src/reflect/presets.rs index 2009b7b..1a47e0c 100644 --- a/librashader-reflect/src/reflect/presets.rs +++ b/librashader-reflect/src/reflect/presets.rs @@ -5,9 +5,9 @@ use crate::front::{ShaderInputCompiler, ShaderReflectObject}; use crate::reflect::semantics::{ Semantic, ShaderSemantics, TextureSemantics, UniformSemantic, UniqueSemantics, }; +use librashader_common::map::FastHashMap; use librashader_preprocess::{PreprocessError, ShaderSource}; use librashader_presets::{ShaderPassConfig, TextureConfig}; -use librashader_common::map::FastHashMap; /// Artifacts of a reflected and compiled shader pass. /// diff --git a/librashader-runtime-d3d11/src/filter_chain.rs b/librashader-runtime-d3d11/src/filter_chain.rs index 845944f..e1285a1 100644 --- a/librashader-runtime-d3d11/src/filter_chain.rs +++ b/librashader-runtime-d3d11/src/filter_chain.rs @@ -1,14 +1,14 @@ use crate::texture::{D3D11InputView, InputTexture, LutTexture}; use librashader_common::{ImageFormat, Size, Viewport}; +use librashader_common::map::FastHashMap; use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig}; use librashader_reflect::back::targets::HLSL; use librashader_reflect::back::{CompileReflectShader, CompileShader}; -use librashader_reflect::front::{SpirvCompilation}; +use librashader_reflect::front::SpirvCompilation; use librashader_reflect::reflect::semantics::ShaderSemantics; use librashader_reflect::reflect::ReflectShader; use librashader_runtime::image::{Image, ImageError, UVDirection}; -use librashader_common::map::FastHashMap; use std::collections::VecDeque; use std::path::Path; diff --git a/librashader-runtime-d3d11/src/filter_pass.rs b/librashader-runtime-d3d11/src/filter_pass.rs index d08465b..1989c7a 100644 --- a/librashader-runtime-d3d11/src/filter_pass.rs +++ b/librashader-runtime-d3d11/src/filter_pass.rs @@ -2,6 +2,7 @@ use crate::filter_chain::FilterCommon; use crate::options::FrameOptionsD3D11; use crate::texture::InputTexture; +use librashader_common::map::FastHashMap; use librashader_common::{ImageFormat, Size, Viewport}; use librashader_preprocess::ShaderSource; use librashader_presets::ShaderPassConfig; @@ -9,7 +10,6 @@ use librashader_reflect::reflect::semantics::{ BindingStage, MemberOffset, TextureBinding, UniformBinding, }; use librashader_reflect::reflect::ShaderReflection; -use librashader_common::map::FastHashMap; use librashader_runtime::binding::{BindSemantics, TextureInput, UniformInputs}; use librashader_runtime::filter_pass::FilterPassMeta; diff --git a/librashader-runtime-d3d11/src/samplers.rs b/librashader-runtime-d3d11/src/samplers.rs index e1c18b4..e8fce74 100644 --- a/librashader-runtime-d3d11/src/samplers.rs +++ b/librashader-runtime-d3d11/src/samplers.rs @@ -1,6 +1,6 @@ use crate::error::{assume_d3d11_init, Result}; -use librashader_common::{FilterMode, WrapMode}; use librashader_common::map::FastHashMap; +use librashader_common::{FilterMode, WrapMode}; use windows::Win32::Graphics::Direct3D11::{ ID3D11Device, ID3D11SamplerState, D3D11_COMPARISON_NEVER, D3D11_FLOAT32_MAX, D3D11_SAMPLER_DESC, D3D11_TEXTURE_ADDRESS_MODE, diff --git a/librashader-runtime-d3d12/src/filter_chain.rs b/librashader-runtime-d3d12/src/filter_chain.rs index d25d2fa..7a36fe3 100644 --- a/librashader-runtime-d3d12/src/filter_chain.rs +++ b/librashader-runtime-d3d12/src/filter_chain.rs @@ -14,11 +14,12 @@ use crate::options::{FilterChainOptionsD3D12, FrameOptionsD3D12}; use crate::samplers::SamplerSet; use crate::texture::{D3D12InputImage, D3D12OutputView, InputTexture, OutputDescriptor}; use crate::{error, util}; +use librashader_common::map::FastHashMap; use librashader_common::{ImageFormat, Size, Viewport}; use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig}; use librashader_reflect::back::targets::{DXIL, HLSL}; use librashader_reflect::back::{CompileReflectShader, CompileShader}; -use librashader_reflect::front::{SpirvCompilation}; +use librashader_reflect::front::SpirvCompilation; use librashader_reflect::reflect::presets::{CompilePresetTarget, ShaderPassArtifact}; use librashader_reflect::reflect::semantics::{ShaderSemantics, MAX_BINDINGS_COUNT}; use librashader_reflect::reflect::ReflectShader; @@ -26,7 +27,6 @@ use librashader_runtime::binding::{BindingUtil, TextureInput}; use librashader_runtime::image::{Image, ImageError, UVDirection}; use librashader_runtime::quad::QuadType; use librashader_runtime::uniforms::UniformStorage; -use librashader_common::map::FastHashMap; use std::collections::VecDeque; use std::mem::ManuallyDrop; use std::path::Path; diff --git a/librashader-runtime-d3d12/src/filter_pass.rs b/librashader-runtime-d3d12/src/filter_pass.rs index e360633..a642ab6 100644 --- a/librashader-runtime-d3d12/src/filter_pass.rs +++ b/librashader-runtime-d3d12/src/filter_pass.rs @@ -6,6 +6,7 @@ use crate::graphics_pipeline::D3D12GraphicsPipeline; use crate::options::FrameOptionsD3D12; use crate::samplers::SamplerSet; use crate::texture::{D3D12OutputView, InputTexture}; +use librashader_common::map::FastHashMap; use librashader_common::{ImageFormat, Size, Viewport}; use librashader_preprocess::ShaderSource; use librashader_presets::ShaderPassConfig; @@ -16,7 +17,6 @@ use librashader_runtime::filter_pass::FilterPassMeta; use librashader_runtime::quad::QuadType; use librashader_runtime::render_target::RenderTarget; use librashader_runtime::uniforms::{NoUniformBinder, UniformStorage}; -use librashader_common::map::FastHashMap; use std::ops::Deref; use windows::core::ComInterface; use windows::Win32::Foundation::RECT; diff --git a/librashader-runtime-d3d12/src/samplers.rs b/librashader-runtime-d3d12/src/samplers.rs index 112b383..89e2613 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 librashader_common::map::FastHashMap; +use librashader_common::{FilterMode, WrapMode}; use std::ops::Deref; use windows::Win32::Graphics::Direct3D12::{ ID3D12Device, D3D12_COMPARISON_FUNC_NEVER, D3D12_FLOAT32_MAX, D3D12_SAMPLER_DESC, diff --git a/librashader-runtime-gl/src/filter_chain/filter_impl.rs b/librashader-runtime-gl/src/filter_chain/filter_impl.rs index 355fc8c..1748b91 100644 --- a/librashader-runtime-gl/src/filter_chain/filter_impl.rs +++ b/librashader-runtime-gl/src/filter_chain/filter_impl.rs @@ -16,10 +16,11 @@ use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig}; use librashader_reflect::back::glsl::GlslVersion; use librashader_reflect::back::targets::GLSL; use librashader_reflect::back::{CompileReflectShader, CompileShader}; -use librashader_reflect::front::{SpirvCompilation}; +use librashader_reflect::front::SpirvCompilation; use librashader_reflect::reflect::semantics::{ShaderSemantics, UniformMeta}; use librashader_cache::CachedCompilation; +use librashader_common::map::FastHashMap; use librashader_reflect::reflect::cross::SpirvCross; use librashader_reflect::reflect::presets::{CompilePresetTarget, ShaderPassArtifact}; use librashader_reflect::reflect::ReflectShader; @@ -27,7 +28,6 @@ use librashader_runtime::binding::BindingUtil; use librashader_runtime::framebuffer::FramebufferInit; use librashader_runtime::render_target::RenderTarget; use librashader_runtime::scaling::ScaleFramebuffer; -use librashader_common::map::FastHashMap; use std::collections::VecDeque; #[rustfmt::skip] diff --git a/librashader-runtime-gl/src/filter_pass.rs b/librashader-runtime-gl/src/filter_pass.rs index def1c1e..42591bd 100644 --- a/librashader-runtime-gl/src/filter_pass.rs +++ b/librashader-runtime-gl/src/filter_pass.rs @@ -1,6 +1,7 @@ use gl::types::{GLint, GLsizei, GLuint}; use librashader_reflect::reflect::ShaderReflection; +use librashader_common::map::FastHashMap; use librashader_common::{ImageFormat, Size, Viewport}; use librashader_preprocess::ShaderSource; use librashader_presets::ShaderPassConfig; @@ -8,7 +9,6 @@ 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 librashader_common::map::FastHashMap; use crate::binding::{GlUniformBinder, GlUniformStorage, UniformLocation, VariableLocation}; use crate::filter_chain::FilterCommon; diff --git a/librashader-runtime-gl/src/gl/gl3/draw_quad.rs b/librashader-runtime-gl/src/gl/gl3/draw_quad.rs index adfa291..f914081 100644 --- a/librashader-runtime-gl/src/gl/gl3/draw_quad.rs +++ b/librashader-runtime-gl/src/gl/gl3/draw_quad.rs @@ -1,7 +1,7 @@ use crate::gl::FINAL_VBO_DATA; use crate::gl::{DrawQuad, OpenGLVertex}; -use gl::types::{GLsizei, GLsizeiptr, GLuint}; use bytemuck::offset_of; +use gl::types::{GLsizei, GLsizeiptr, GLuint}; pub struct Gl3DrawQuad { vbo: GLuint, diff --git a/librashader-runtime-gl/src/gl/gl3/lut_load.rs b/librashader-runtime-gl/src/gl/gl3/lut_load.rs index 8d64e9d..cf5e85c 100644 --- a/librashader-runtime-gl/src/gl/gl3/lut_load.rs +++ b/librashader-runtime-gl/src/gl/gl3/lut_load.rs @@ -3,11 +3,11 @@ use crate::framebuffer::GLImage; use crate::gl::LoadLut; use crate::texture::InputTexture; use gl::types::{GLsizei, GLuint}; +use librashader_common::map::FastHashMap; use librashader_presets::TextureConfig; use librashader_runtime::image::{Image, ImageError, UVDirection}; use librashader_runtime::scaling::MipmapSize; use rayon::prelude::*; -use librashader_common::map::FastHashMap; pub struct Gl3LutLoad; impl LoadLut for Gl3LutLoad { diff --git a/librashader-runtime-gl/src/gl/gl46/draw_quad.rs b/librashader-runtime-gl/src/gl/gl46/draw_quad.rs index ca9327b..9ff8499 100644 --- a/librashader-runtime-gl/src/gl/gl46/draw_quad.rs +++ b/librashader-runtime-gl/src/gl/gl46/draw_quad.rs @@ -1,7 +1,7 @@ use crate::gl::FINAL_VBO_DATA; use crate::gl::{DrawQuad, OpenGLVertex}; -use gl::types::{GLint, GLsizeiptr, GLuint}; use bytemuck::offset_of; +use gl::types::{GLint, GLsizeiptr, GLuint}; pub struct Gl46DrawQuad { vbo: GLuint, diff --git a/librashader-runtime-gl/src/gl/gl46/lut_load.rs b/librashader-runtime-gl/src/gl/gl46/lut_load.rs index f022613..5b59c48 100644 --- a/librashader-runtime-gl/src/gl/gl46/lut_load.rs +++ b/librashader-runtime-gl/src/gl/gl46/lut_load.rs @@ -3,11 +3,11 @@ use crate::framebuffer::GLImage; use crate::gl::LoadLut; use crate::texture::InputTexture; use gl::types::{GLsizei, GLuint}; +use librashader_common::map::FastHashMap; use librashader_presets::TextureConfig; use librashader_runtime::image::{Image, ImageError, UVDirection}; use librashader_runtime::scaling::MipmapSize; use rayon::prelude::*; -use librashader_common::map::FastHashMap; pub struct Gl46LutLoad; impl LoadLut for Gl46LutLoad { diff --git a/librashader-runtime-gl/src/gl/mod.rs b/librashader-runtime-gl/src/gl/mod.rs index edcf93c..42fcb9c 100644 --- a/librashader-runtime-gl/src/gl/mod.rs +++ b/librashader-runtime-gl/src/gl/mod.rs @@ -10,13 +10,13 @@ use crate::texture::InputTexture; use bytemuck::{Pod, Zeroable}; pub use framebuffer::GLFramebuffer; use gl::types::{GLenum, GLuint}; +use librashader_common::map::FastHashMap; use librashader_common::{ImageFormat, Size}; use librashader_presets::{Scale2D, TextureConfig}; use librashader_reflect::back::glsl::CrossGlslContext; use librashader_reflect::back::ShaderCompilerOutput; use librashader_reflect::reflect::semantics::{BufferReflection, TextureBinding}; use librashader_runtime::uniforms::UniformStorageAccess; -use librashader_common::map::FastHashMap; #[repr(C)] #[derive(Debug, Copy, Clone, Default, Zeroable, Pod)] diff --git a/librashader-runtime-gl/src/samplers.rs b/librashader-runtime-gl/src/samplers.rs index f564ba5..c3a1e4c 100644 --- a/librashader-runtime-gl/src/samplers.rs +++ b/librashader-runtime-gl/src/samplers.rs @@ -1,6 +1,6 @@ use gl::types::{GLenum, GLint, GLuint}; -use librashader_common::{FilterMode, WrapMode}; use librashader_common::map::FastHashMap; +use librashader_common::{FilterMode, WrapMode}; pub struct SamplerSet { // todo: may need to deal with differences in mip filter. diff --git a/librashader-runtime-mtl/src/filter_chain.rs b/librashader-runtime-mtl/src/filter_chain.rs index c115482..4a8134f 100644 --- a/librashader-runtime-mtl/src/filter_chain.rs +++ b/librashader-runtime-mtl/src/filter_chain.rs @@ -14,6 +14,7 @@ use icrate::Metal::{ MTLPixelFormat, MTLPixelFormatRGBA8Unorm, MTLRenderPassDescriptor, MTLResource, MTLStoreActionDontCare, MTLStoreActionStore, MTLTexture, }; +use librashader_common::map::FastHashMap; use librashader_common::{ImageFormat, Size, Viewport}; use librashader_presets::context::VideoDriver; use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig}; @@ -35,7 +36,6 @@ use librashader_runtime::uniforms::UniformStorage; use objc2::rc::Id; use objc2::runtime::ProtocolObject; use rayon::prelude::*; -use librashader_common::map::FastHashMap; use std::collections::VecDeque; use std::fmt::{Debug, Formatter}; use std::path::Path; diff --git a/librashader-runtime-mtl/src/filter_pass.rs b/librashader-runtime-mtl/src/filter_pass.rs index cd4880f..d465700 100644 --- a/librashader-runtime-mtl/src/filter_pass.rs +++ b/librashader-runtime-mtl/src/filter_pass.rs @@ -6,6 +6,7 @@ use crate::options::FrameOptionsMetal; use crate::samplers::SamplerSet; use crate::texture::{get_texture_size, InputTexture}; use icrate::Metal::{MTLCommandBuffer, MTLCommandEncoder, MTLRenderCommandEncoder, MTLTexture}; +use librashader_common::map::FastHashMap; use librashader_common::{ImageFormat, Size, Viewport}; use librashader_preprocess::ShaderSource; use librashader_presets::ShaderPassConfig; @@ -17,7 +18,6 @@ use librashader_runtime::quad::QuadType; use librashader_runtime::render_target::RenderTarget; use librashader_runtime::uniforms::{NoUniformBinder, UniformStorage}; use objc2::runtime::ProtocolObject; -use librashader_common::map::FastHashMap; impl TextureInput for InputTexture { fn size(&self) -> Size { diff --git a/librashader-runtime-mtl/src/graphics_pipeline.rs b/librashader-runtime-mtl/src/graphics_pipeline.rs index 61d97c9..e4539e2 100644 --- a/librashader-runtime-mtl/src/graphics_pipeline.rs +++ b/librashader-runtime-mtl/src/graphics_pipeline.rs @@ -1,6 +1,7 @@ use crate::draw_quad::MetalVertex; use crate::error::{FilterChainError, Result}; use crate::select_optimal_pixel_format; +use bytemuck::offset_of; use icrate::Foundation::NSString; use icrate::Metal::{ MTLBlendFactorOneMinusSourceAlpha, MTLBlendFactorSourceAlpha, MTLCommandBuffer, @@ -16,7 +17,6 @@ use librashader_reflect::back::ShaderCompilerOutput; use librashader_runtime::render_target::RenderTarget; use objc2::rc::Id; use objc2::runtime::ProtocolObject; -use bytemuck::offset_of; /// This is only really plausible for SPIRV-Cross, for Naga we need to supply the next plausible binding. pub const VERTEX_BUFFER_INDEX: usize = 4; diff --git a/librashader-runtime-mtl/src/samplers.rs b/librashader-runtime-mtl/src/samplers.rs index 10ec165..423384d 100644 --- a/librashader-runtime-mtl/src/samplers.rs +++ b/librashader-runtime-mtl/src/samplers.rs @@ -3,10 +3,10 @@ use icrate::Metal::{ MTLSamplerBorderColorTransparentBlack, MTLSamplerDescriptor, MTLSamplerMinMagFilter, MTLSamplerState, }; +use librashader_common::map::FastHashMap; use librashader_common::{FilterMode, WrapMode}; use objc2::rc::Id; use objc2::runtime::ProtocolObject; -use librashader_common::map::FastHashMap; use crate::error::{FilterChainError, Result}; diff --git a/librashader-runtime-vk/src/filter_chain.rs b/librashader-runtime-vk/src/filter_chain.rs index 6b267f9..99104fb 100644 --- a/librashader-runtime-vk/src/filter_chain.rs +++ b/librashader-runtime-vk/src/filter_chain.rs @@ -14,10 +14,11 @@ use ash::vk; use librashader_common::{ImageFormat, Size, Viewport}; use gpu_allocator::vulkan::Allocator; +use librashader_common::map::FastHashMap; use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig}; use librashader_reflect::back::targets::SPIRV; use librashader_reflect::back::{CompileReflectShader, CompileShader}; -use librashader_reflect::front::{SpirvCompilation}; +use librashader_reflect::front::SpirvCompilation; use librashader_reflect::reflect::presets::{CompilePresetTarget, ShaderPassArtifact}; use librashader_reflect::reflect::semantics::ShaderSemantics; use librashader_reflect::reflect::ReflectShader; @@ -26,7 +27,6 @@ use librashader_runtime::image::{Image, ImageError, UVDirection, BGRA8}; use librashader_runtime::quad::QuadType; use librashader_runtime::uniforms::UniformStorage; use parking_lot::RwLock; -use librashader_common::map::FastHashMap; use std::collections::VecDeque; use std::convert::Infallible; use std::path::Path; diff --git a/librashader-runtime-vk/src/filter_pass.rs b/librashader-runtime-vk/src/filter_pass.rs index 4c5d3d1..37f1737 100644 --- a/librashader-runtime-vk/src/filter_pass.rs +++ b/librashader-runtime-vk/src/filter_pass.rs @@ -7,6 +7,7 @@ use crate::samplers::SamplerSet; use crate::texture::InputImage; use crate::{error, VulkanImage}; use ash::vk; +use librashader_common::map::FastHashMap; use librashader_common::{ImageFormat, Size, Viewport}; use librashader_preprocess::ShaderSource; use librashader_presets::ShaderPassConfig; @@ -19,7 +20,6 @@ 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 librashader_common::map::FastHashMap; use std::sync::Arc; pub struct FilterPass { diff --git a/librashader-runtime-vk/src/samplers.rs b/librashader-runtime-vk/src/samplers.rs index 76bbe9e..2d426f5 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 librashader_common::map::FastHashMap; +use librashader_common::{FilterMode, WrapMode}; use std::sync::Arc; pub struct VulkanSampler { diff --git a/librashader-runtime-wgpu/src/filter_chain.rs b/librashader-runtime-wgpu/src/filter_chain.rs index 37559bf..1385aec 100644 --- a/librashader-runtime-wgpu/src/filter_chain.rs +++ b/librashader-runtime-wgpu/src/filter_chain.rs @@ -1,7 +1,8 @@ +use librashader_common::map::FastHashMap; use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig}; use librashader_reflect::back::targets::WGSL; use librashader_reflect::back::{CompileReflectShader, CompileShader}; -use librashader_reflect::front::{SpirvCompilation}; +use librashader_reflect::front::SpirvCompilation; use librashader_reflect::reflect::presets::{CompilePresetTarget, ShaderPassArtifact}; use librashader_reflect::reflect::semantics::ShaderSemantics; use librashader_reflect::reflect::ReflectShader; @@ -11,7 +12,6 @@ use librashader_runtime::quad::QuadType; use librashader_runtime::uniforms::UniformStorage; #[cfg(not(target_arch = "wasm32"))] use rayon::prelude::*; -use librashader_common::map::FastHashMap; use std::collections::VecDeque; use std::path::Path; diff --git a/librashader-runtime-wgpu/src/filter_pass.rs b/librashader-runtime-wgpu/src/filter_pass.rs index 7a725f1..5481041 100644 --- a/librashader-runtime-wgpu/src/filter_pass.rs +++ b/librashader-runtime-wgpu/src/filter_pass.rs @@ -6,6 +6,7 @@ use crate::graphics_pipeline::WgpuGraphicsPipeline; use crate::options::FrameOptionsWgpu; use crate::samplers::SamplerSet; use crate::texture::InputImage; +use librashader_common::map::FastHashMap; use librashader_common::{ImageFormat, Size, Viewport}; use librashader_preprocess::ShaderSource; use librashader_presets::ShaderPassConfig; @@ -18,7 +19,6 @@ 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 librashader_common::map::FastHashMap; use std::sync::Arc; use wgpu::{BindGroupDescriptor, BindGroupEntry, BindingResource, BufferBinding, ShaderStages}; diff --git a/librashader-runtime-wgpu/src/samplers.rs b/librashader-runtime-wgpu/src/samplers.rs index 1fe54d7..1aedae8 100644 --- a/librashader-runtime-wgpu/src/samplers.rs +++ b/librashader-runtime-wgpu/src/samplers.rs @@ -1,5 +1,5 @@ -use librashader_common::{FilterMode, WrapMode}; use librashader_common::map::FastHashMap; +use librashader_common::{FilterMode, WrapMode}; use std::sync::Arc; use wgpu::{Sampler, SamplerBorderColor, SamplerDescriptor}; diff --git a/librashader-runtime/src/binding.rs b/librashader-runtime/src/binding.rs index be53e94..ff28cab 100644 --- a/librashader-runtime/src/binding.rs +++ b/librashader-runtime/src/binding.rs @@ -1,4 +1,5 @@ use crate::uniforms::{BindUniform, NoUniformBinder, UniformStorage}; +use librashader_common::map::FastHashMap; use librashader_common::Size; use librashader_preprocess::ShaderParameter; use librashader_reflect::reflect::semantics::{ @@ -6,7 +7,6 @@ use librashader_reflect::reflect::semantics::{ UniformMeta, UniqueSemantics, }; use std::ops::{Deref, DerefMut}; -use librashader_common::map::FastHashMap; /// Trait for input textures used during uniform binding, pub trait TextureInput { diff --git a/librashader-runtime/src/parameters.rs b/librashader-runtime/src/parameters.rs index e1d93dc..1ba9add 100644 --- a/librashader-runtime/src/parameters.rs +++ b/librashader-runtime/src/parameters.rs @@ -7,7 +7,9 @@ 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<'a>(&'a self) -> ::librashader_common::map::halfbrown::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 +32,9 @@ macro_rules! impl_filter_chain_parameters { self.common.config.passes_enabled = count } - fn enumerate_parameters<'a>(&'a self) -> ::librashader_common::map::halfbrown::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 e409cbd..beef9f6 100644 --- a/librashader/src/lib.rs +++ b/librashader/src/lib.rs @@ -64,9 +64,10 @@ pub mod presets { let iters: Result>, PreprocessError> = preset .shaders .iter() - .map(|s| ShaderSource::load(&s.name).map(|s| - s.parameters.into_iter() - .map(|(_,v)| v).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()) @@ -297,11 +298,16 @@ pub mod runtime { #[cfg(feature = "runtime-wgpu")] #[doc(cfg(feature = "runtime-wgpu"))] /// Shader runtime for wgpu. - #[cfg_attr(all(feature = "runtime-wgpu", all(target_vendor = "apple", feature = "docsrs")), + #[cfg_attr( + all( + feature = "runtime-wgpu", + all(target_vendor = "apple", feature = "docsrs") + ), doc = "\n\nThe wgpu runtime is available on macOS and iOS, but technical reasons prevent them from rendering on docs.rs. \n\n This is because wgpu on macOS and iOS link to [metal-rs](https://github.com/gfx-rs/metal-rs), which can not build on docs.rs. See [SSheldon/rustc-objc-exception#13](https://github.com/SSheldon/rust-objc-exception/issues/13) for more details. -\n\n The wgpu runtime is identical for all supported operating systems, so please refer to documentation from another operating system.")] +\n\n The wgpu runtime is identical for all supported operating systems, so please refer to documentation from another operating system." + )] pub mod wgpu { #[cfg(not(all(target_vendor = "apple", feature = "docsrs")))] pub use librashader_runtime_wgpu::{