fmt: run cargo fmt

This commit is contained in:
chyyran 2023-01-15 18:21:01 -05:00
parent b0948dd951
commit c059e7c566
4 changed files with 22 additions and 17 deletions

View file

@ -6,8 +6,8 @@ mod stage;
use crate::include::read_source; use crate::include::read_source;
pub use error::*; pub use error::*;
use librashader_common::ImageFormat; use librashader_common::ImageFormat;
use std::path::Path;
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use std::path::Path;
/// The source file for a single shader pass. /// The source file for a single shader pass.
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
@ -72,8 +72,7 @@ pub(crate) fn load_shader_source(path: impl AsRef<Path>) -> Result<ShaderSource,
let source = read_source(path)?; let source = read_source(path)?;
let meta = pragma::parse_pragma_meta(&source)?; let meta = pragma::parse_pragma_meta(&source)?;
let text = stage::process_stages(&source)?; let text = stage::process_stages(&source)?;
let parameters = FxHashMap::from_iter(meta.parameters.into_iter() let parameters = FxHashMap::from_iter(meta.parameters.into_iter().map(|p| (p.id.clone(), p)));
.map(|p| (p.id.clone(), p)));
Ok(ShaderSource { Ok(ShaderSource {
vertex: text.vertex, vertex: text.vertex,

View file

@ -186,13 +186,17 @@ impl VulkanWindow {
vk::ImageLayout::UNDEFINED, vk::ImageLayout::UNDEFINED,
vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL, vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL,
vk::AccessFlags::MEMORY_READ vk::AccessFlags::MEMORY_READ
| vk::AccessFlags::MEMORY_WRITE | vk::AccessFlags::HOST_READ | vk::AccessFlags::HOST_WRITE | vk::AccessFlags::MEMORY_WRITE
| vk::AccessFlags::COLOR_ATTACHMENT_READ | vk::AccessFlags::COLOR_ATTACHMENT_WRITE | vk::AccessFlags::SHADER_READ, | vk::AccessFlags::HOST_READ
| vk::AccessFlags::HOST_WRITE
| vk::AccessFlags::COLOR_ATTACHMENT_READ
| vk::AccessFlags::COLOR_ATTACHMENT_WRITE
| vk::AccessFlags::SHADER_READ,
vk::AccessFlags::COLOR_ATTACHMENT_WRITE | vk::AccessFlags::COLOR_ATTACHMENT_READ, vk::AccessFlags::COLOR_ATTACHMENT_WRITE | vk::AccessFlags::COLOR_ATTACHMENT_READ,
vk::PipelineStageFlags::ALL_COMMANDS, vk::PipelineStageFlags::ALL_COMMANDS,
vk::PipelineStageFlags::COLOR_ATTACHMENT_OUTPUT, vk::PipelineStageFlags::COLOR_ATTACHMENT_OUTPUT,
vk::QUEUE_FAMILY_IGNORED, vk::QUEUE_FAMILY_IGNORED,
vk::QUEUE_FAMILY_IGNORED vk::QUEUE_FAMILY_IGNORED,
); );
Self::record_command_buffer(vulkan, framebuffer, cmd); Self::record_command_buffer(vulkan, framebuffer, cmd);
@ -205,13 +209,17 @@ impl VulkanWindow {
vk::ImageLayout::SHADER_READ_ONLY_OPTIMAL, vk::ImageLayout::SHADER_READ_ONLY_OPTIMAL,
vk::ImageLayout::SHADER_READ_ONLY_OPTIMAL, vk::ImageLayout::SHADER_READ_ONLY_OPTIMAL,
vk::AccessFlags::MEMORY_READ vk::AccessFlags::MEMORY_READ
| vk::AccessFlags::MEMORY_WRITE | vk::AccessFlags::HOST_READ | vk::AccessFlags::HOST_WRITE | vk::AccessFlags::MEMORY_WRITE
| vk::AccessFlags::COLOR_ATTACHMENT_READ | vk::AccessFlags::COLOR_ATTACHMENT_WRITE | vk::AccessFlags::SHADER_READ, | vk::AccessFlags::HOST_READ
| vk::AccessFlags::HOST_WRITE
| vk::AccessFlags::COLOR_ATTACHMENT_READ
| vk::AccessFlags::COLOR_ATTACHMENT_WRITE
| vk::AccessFlags::SHADER_READ,
vk::AccessFlags::SHADER_READ, vk::AccessFlags::SHADER_READ,
vk::PipelineStageFlags::ALL_COMMANDS, vk::PipelineStageFlags::ALL_COMMANDS,
vk::PipelineStageFlags::FRAGMENT_SHADER, vk::PipelineStageFlags::FRAGMENT_SHADER,
vk::QUEUE_FAMILY_IGNORED, vk::QUEUE_FAMILY_IGNORED,
vk::QUEUE_FAMILY_IGNORED vk::QUEUE_FAMILY_IGNORED,
); );
// //
// util::vulkan_image_layout_transition_levels( // util::vulkan_image_layout_transition_levels(

View file

@ -238,12 +238,12 @@ where
{ {
let id = id.as_str(); let id = id.as_str();
let default = parameter_defaults.get(id) let default = parameter_defaults
.get(id)
.map(|f| f.initial) .map(|f| f.initial)
.unwrap_or(0f32); .unwrap_or(0f32);
let value = *runtime_parameters.get(id) let value = *runtime_parameters.get(id).unwrap_or(&default);
.unwrap_or(&default);
uniform_storage.bind_scalar(offset.offset(), value, offset.context()); uniform_storage.bind_scalar(offset.offset(), value, offset.context());
} }

View file

@ -14,8 +14,8 @@
//! called with appropriate input and output parameters to draw a frame with the shader effect applied. //! called with appropriate input and output parameters to draw a frame with the shader effect applied.
//! //!
//! ## Runtimes //! ## Runtimes
//! Currently available runtimes are OpenGL 3.3+ and 4.6 (with DSA), and Direct3D 11. //! Currently available runtimes are Vulkan 1.3+, OpenGL 3.3+ and 4.6 (with DSA), and Direct3D 11.
//! Work on the Vulkan and Direct3D 12 runtimes are in progress. //! Work on the Direct3D 12 runtimes are in progress. The Vulkan runtime requires [`VK_KHR_dynamic_rendering`](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_dynamic_rendering.html).
//! //!
//! | **API** | **Status** | **`librashader` feature** | //! | **API** | **Status** | **`librashader` feature** |
//! |-------------|------------|---------------------------| //! |-------------|------------|---------------------------|
@ -47,9 +47,7 @@ pub mod presets {
let iters: Result<Vec<Vec<ShaderParameter>>, PreprocessError> = preset let iters: Result<Vec<Vec<ShaderParameter>>, PreprocessError> = preset
.shaders .shaders
.iter() .iter()
.map(|s| ShaderSource::load(&s.name).map(|s| .map(|s| ShaderSource::load(&s.name).map(|s| s.parameters.into_values().collect()))
s.parameters.into_values()
.collect()))
.into_iter() .into_iter()
.collect(); .collect();
let iters = iters?; let iters = iters?;