fmt: general format and clean up
This commit is contained in:
parent
c8a1d4d196
commit
6d75dc5100
13 changed files with 43 additions and 67 deletions
|
@ -32,6 +32,7 @@ pub struct ShaderPassConfig {
|
|||
impl ShaderPassConfig {
|
||||
/// If the framebuffer expects a different format than what was defined in the
|
||||
/// shader source, returns such format.
|
||||
#[inline(always)]
|
||||
pub fn get_format_override(&self) -> Option<ImageFormat> {
|
||||
if self.srgb_framebuffer {
|
||||
return Some(ImageFormat::R8G8B8A8Srgb);
|
||||
|
@ -40,6 +41,15 @@ impl ShaderPassConfig {
|
|||
}
|
||||
None
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn get_frame_count(&self, count: usize) -> u32 {
|
||||
(if self.frame_count_mod > 0 {
|
||||
count % self.frame_count_mod as usize
|
||||
} else {
|
||||
count
|
||||
}) as u32
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(i32)]
|
||||
|
|
|
@ -25,9 +25,8 @@ use crate::util::d3d11_compile_bound_shader;
|
|||
use crate::{error, util, D3D11OutputView};
|
||||
use librashader_reflect::reflect::presets::{CompilePresetTarget, ShaderPassArtifact};
|
||||
use librashader_runtime::binding::{BindingUtil, TextureInput};
|
||||
use librashader_runtime::filter_pass::FilterPassMeta;
|
||||
use librashader_runtime::quad::{QuadType, IDENTITY_MVP};
|
||||
use librashader_runtime::scaling::{scale_framebuffers, scale_framebuffers_with_context_callback};
|
||||
use librashader_runtime::scaling::scale_framebuffers;
|
||||
use librashader_runtime::uniforms::UniformStorage;
|
||||
use rayon::prelude::*;
|
||||
use windows::Win32::Graphics::Direct3D11::{
|
||||
|
@ -299,7 +298,7 @@ impl FilterChainD3D11 {
|
|||
uniform_buffer: ubo_cbuffer,
|
||||
push_buffer: push_cbuffer,
|
||||
source,
|
||||
config: config.clone(),
|
||||
config,
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
|
@ -454,7 +453,7 @@ impl FilterChainD3D11 {
|
|||
viewport.output.size,
|
||||
&mut self.output_framebuffers,
|
||||
&mut self.feedback_framebuffers,
|
||||
&passes,
|
||||
passes,
|
||||
)?;
|
||||
|
||||
let passes_len = passes.len();
|
||||
|
@ -473,11 +472,7 @@ impl FilterChainD3D11 {
|
|||
pass.draw(
|
||||
index,
|
||||
&self.common,
|
||||
if pass.config.frame_count_mod > 0 {
|
||||
frame_count % pass.config.frame_count_mod as usize
|
||||
} else {
|
||||
frame_count
|
||||
} as u32,
|
||||
pass.config.get_frame_count(frame_count),
|
||||
frame_direction,
|
||||
viewport,
|
||||
&original,
|
||||
|
@ -505,16 +500,12 @@ impl FilterChainD3D11 {
|
|||
pass.draw(
|
||||
passes_len - 1,
|
||||
&self.common,
|
||||
if pass.config.frame_count_mod > 0 {
|
||||
frame_count % pass.config.frame_count_mod as usize
|
||||
} else {
|
||||
frame_count
|
||||
} as u32,
|
||||
pass.config.get_frame_count(frame_count),
|
||||
frame_direction,
|
||||
viewport,
|
||||
&original,
|
||||
&source,
|
||||
viewport.into(),
|
||||
RenderTarget::from(viewport),
|
||||
QuadType::Final,
|
||||
)?;
|
||||
}
|
||||
|
|
|
@ -90,12 +90,12 @@ impl D3D11State {
|
|||
let saved_rs = context.RSGetState().ok();
|
||||
|
||||
D3D11StateSaveGuard {
|
||||
ctx: &context,
|
||||
ctx: context,
|
||||
saved_blend,
|
||||
saved_blend_factor,
|
||||
saved_blend_mask,
|
||||
saved_rs,
|
||||
state: &self,
|
||||
state: self,
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ mod tests {
|
|||
use super::*;
|
||||
use crate::options::FilterChainOptionsD3D11;
|
||||
use librashader_runtime::image::{Image, UVDirection};
|
||||
use std::env;
|
||||
|
||||
// "../test/slang-shaders/scalefx/scalefx-9x.slangp",
|
||||
// "../test/slang-shaders/bezel/koko-aio/monitor-bloom.slangp",
|
||||
|
|
|
@ -46,7 +46,6 @@ use windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT_UNKNOWN;
|
|||
use windows::Win32::System::Threading::{CreateEventA, ResetEvent, WaitForSingleObject};
|
||||
use windows::Win32::System::WindowsProgramming::INFINITE;
|
||||
|
||||
use librashader_runtime::filter_pass::FilterPassMeta;
|
||||
use librashader_runtime::scaling::{scale_framebuffers_with_context_callback, MipmapSize};
|
||||
use rayon::prelude::*;
|
||||
|
||||
|
@ -531,7 +530,7 @@ impl FilterChainD3D12 {
|
|||
frame_count: usize,
|
||||
options: Option<&FrameOptionsD3D12>,
|
||||
) -> error::Result<()> {
|
||||
drop(self.residuals.drain(..));
|
||||
self.residuals.clear();
|
||||
|
||||
if let Some(options) = options {
|
||||
if options.clear_history {
|
||||
|
@ -585,7 +584,7 @@ impl FilterChainD3D12 {
|
|||
}
|
||||
|
||||
let original = unsafe { InputTexture::new_from_raw(input, filter, wrap_mode) };
|
||||
let mut source = unsafe { original.clone() };
|
||||
let mut source = original.clone();
|
||||
|
||||
// swap output and feedback **before** recording command buffers
|
||||
std::mem::swap(
|
||||
|
@ -599,7 +598,7 @@ impl FilterChainD3D12 {
|
|||
viewport.output.size,
|
||||
&mut self.output_framebuffers,
|
||||
&mut self.feedback_framebuffers,
|
||||
&passes,
|
||||
passes,
|
||||
(),
|
||||
|index: usize, pass: &FilterPass, output: &OwnedImage, feedback: &OwnedImage| {
|
||||
// refresh inputs
|
||||
|
@ -676,11 +675,7 @@ impl FilterChainD3D12 {
|
|||
cmd,
|
||||
index,
|
||||
&self.common,
|
||||
if pass.config.frame_count_mod > 0 {
|
||||
frame_count % pass.config.frame_count_mod as usize
|
||||
} else {
|
||||
frame_count
|
||||
} as u32,
|
||||
pass.config.get_frame_count(frame_count),
|
||||
frame_direction,
|
||||
viewport,
|
||||
&original,
|
||||
|
@ -717,11 +712,7 @@ impl FilterChainD3D12 {
|
|||
cmd,
|
||||
passes_len - 1,
|
||||
&self.common,
|
||||
if pass.config.frame_count_mod > 0 {
|
||||
frame_count % pass.config.frame_count_mod as usize
|
||||
} else {
|
||||
frame_count
|
||||
} as u32,
|
||||
pass.config.get_frame_count(frame_count),
|
||||
frame_direction,
|
||||
viewport,
|
||||
&original,
|
||||
|
|
|
@ -232,7 +232,7 @@ pub fn d3d12_get_resource_transition_subresource(
|
|||
after: D3D12_RESOURCE_STATES,
|
||||
subresource: u32,
|
||||
) -> D3D12_RESOURCE_BARRIER {
|
||||
let barrier = D3D12_RESOURCE_BARRIER {
|
||||
D3D12_RESOURCE_BARRIER {
|
||||
Type: D3D12_RESOURCE_BARRIER_TYPE_TRANSITION,
|
||||
Flags: D3D12_RESOURCE_BARRIER_FLAG_NONE,
|
||||
Anonymous: D3D12_RESOURCE_BARRIER_0 {
|
||||
|
@ -243,9 +243,7 @@ pub fn d3d12_get_resource_transition_subresource(
|
|||
StateAfter: after,
|
||||
}),
|
||||
},
|
||||
};
|
||||
|
||||
barrier
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
|
|
@ -21,7 +21,6 @@ use librashader_reflect::reflect::semantics::{BindingMeta, ShaderSemantics, Unif
|
|||
use librashader_reflect::reflect::presets::{CompilePresetTarget, ShaderPassArtifact};
|
||||
use librashader_reflect::reflect::ReflectShader;
|
||||
use librashader_runtime::binding::BindingUtil;
|
||||
use librashader_runtime::filter_pass::FilterPassMeta;
|
||||
use librashader_runtime::scaling::scale_framebuffers;
|
||||
use rustc_hash::FxHashMap;
|
||||
use spirv_cross::spirv::Decoration;
|
||||
|
@ -319,7 +318,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
|
|||
/// When this frame returns, GL_FRAMEBUFFER is bound to 0.
|
||||
pub fn frame(
|
||||
&mut self,
|
||||
count: usize,
|
||||
frame_count: usize,
|
||||
viewport: &Viewport<&Framebuffer>,
|
||||
input: &GLImage,
|
||||
options: Option<&FrameOptionsGL>,
|
||||
|
@ -386,7 +385,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
|
|||
viewport.output.size,
|
||||
&mut self.output_framebuffers,
|
||||
&mut self.feedback_framebuffers,
|
||||
&passes,
|
||||
passes,
|
||||
)?;
|
||||
|
||||
let passes_len = passes.len();
|
||||
|
@ -401,11 +400,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
|
|||
pass.draw(
|
||||
index,
|
||||
&self.common,
|
||||
if pass.config.frame_count_mod > 0 {
|
||||
count % pass.config.frame_count_mod as usize
|
||||
} else {
|
||||
count
|
||||
} as u32,
|
||||
pass.config.get_frame_count(frame_count),
|
||||
frame_direction,
|
||||
viewport,
|
||||
&original,
|
||||
|
@ -428,11 +423,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
|
|||
pass.draw(
|
||||
passes_len - 1,
|
||||
&self.common,
|
||||
if pass.config.frame_count_mod > 0 {
|
||||
count % pass.config.frame_count_mod as usize
|
||||
} else {
|
||||
count
|
||||
} as u32,
|
||||
pass.config.get_frame_count(frame_count),
|
||||
frame_direction,
|
||||
viewport,
|
||||
&original,
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::framebuffer::GLImage;
|
|||
use crate::gl::FramebufferInterface;
|
||||
use crate::texture::InputTexture;
|
||||
use gl::types::{GLenum, GLuint};
|
||||
use librashader_common::{FilterMode, ImageFormat, Size, Viewport, WrapMode};
|
||||
use librashader_common::{FilterMode, ImageFormat, Size, WrapMode};
|
||||
use librashader_presets::Scale2D;
|
||||
use librashader_runtime::scaling::ScaleableFramebuffer;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::framebuffer::GLImage;
|
|||
use crate::gl::framebuffer::Framebuffer;
|
||||
use crate::gl::FramebufferInterface;
|
||||
use gl::types::{GLenum, GLint, GLsizei};
|
||||
use librashader_common::{ImageFormat, Size, Viewport};
|
||||
use librashader_common::{ImageFormat, Size};
|
||||
use librashader_presets::Scale2D;
|
||||
use librashader_runtime::scaling::{MipmapSize, ViewportSize};
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::framebuffer::GLImage;
|
|||
use crate::gl::framebuffer::Framebuffer;
|
||||
use crate::gl::FramebufferInterface;
|
||||
use gl::types::{GLenum, GLint, GLsizei};
|
||||
use librashader_common::{ImageFormat, Size, Viewport};
|
||||
use librashader_common::{ImageFormat, Size};
|
||||
use librashader_presets::Scale2D;
|
||||
use librashader_runtime::scaling::{MipmapSize, ViewportSize};
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ use crate::samplers::SamplerSet;
|
|||
use crate::texture::InputTexture;
|
||||
pub use framebuffer::Framebuffer;
|
||||
use gl::types::{GLenum, GLuint};
|
||||
use librashader_common::{ImageFormat, Size, Viewport};
|
||||
use librashader_common::{ImageFormat, Size};
|
||||
use librashader_presets::{Scale2D, TextureConfig};
|
||||
use librashader_reflect::reflect::semantics::{TextureBinding, UboReflection};
|
||||
use librashader_runtime::uniforms::UniformStorageAccess;
|
||||
|
|
|
@ -8,7 +8,6 @@ use crate::queue_selection::get_graphics_queue;
|
|||
use crate::render_target::RenderTarget;
|
||||
use crate::samplers::SamplerSet;
|
||||
use crate::texture::{InputImage, OwnedImage, OwnedImageLayout, VulkanImage};
|
||||
// use crate::ubo_ring::VkUboRing;
|
||||
use crate::vulkan_primitives::RawVulkanBuffer;
|
||||
use crate::vulkan_state::VulkanGraphicsPipeline;
|
||||
use crate::{error, util};
|
||||
|
@ -31,7 +30,6 @@ use std::collections::VecDeque;
|
|||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
|
||||
use librashader_runtime::filter_pass::FilterPassMeta;
|
||||
use librashader_runtime::scaling::scale_framebuffers_with_context_callback;
|
||||
use rayon::prelude::*;
|
||||
|
||||
|
@ -539,10 +537,10 @@ impl FilterChainVulkan {
|
|||
input: &VulkanImage,
|
||||
viewport: &Viewport<VulkanImage>,
|
||||
cmd: vk::CommandBuffer,
|
||||
count: usize,
|
||||
frame_count: usize,
|
||||
options: Option<&FrameOptionsVulkan>,
|
||||
) -> error::Result<()> {
|
||||
let intermediates = &mut self.residuals[count % self.residuals.len()];
|
||||
let intermediates = &mut self.residuals[frame_count % self.residuals.len()];
|
||||
intermediates.dispose();
|
||||
|
||||
// limit number of passes to those enabled.
|
||||
|
@ -621,7 +619,7 @@ impl FilterChainVulkan {
|
|||
viewport.output.size,
|
||||
&mut self.output_framebuffers,
|
||||
&mut self.feedback_framebuffers,
|
||||
&passes,
|
||||
passes,
|
||||
Some(OwnedImageLayout {
|
||||
dst_layout: vk::ImageLayout::SHADER_READ_ONLY_OPTIMAL,
|
||||
dst_access: vk::AccessFlags::SHADER_READ,
|
||||
|
@ -662,11 +660,7 @@ impl FilterChainVulkan {
|
|||
cmd,
|
||||
index,
|
||||
&self.common,
|
||||
if pass.config.frame_count_mod > 0 {
|
||||
count % pass.config.frame_count_mod as usize
|
||||
} else {
|
||||
count
|
||||
} as u32,
|
||||
pass.config.get_frame_count(frame_count),
|
||||
frame_direction,
|
||||
viewport,
|
||||
&original,
|
||||
|
@ -704,8 +698,8 @@ impl FilterChainVulkan {
|
|||
cmd,
|
||||
passes_len - 1,
|
||||
&self.common,
|
||||
count as u32,
|
||||
0,
|
||||
pass.config.get_frame_count(frame_count),
|
||||
frame_direction,
|
||||
viewport,
|
||||
&original,
|
||||
&source,
|
||||
|
@ -717,7 +711,7 @@ impl FilterChainVulkan {
|
|||
intermediates.dispose_framebuffers(residual_fb);
|
||||
}
|
||||
|
||||
self.push_history(input, cmd, count)?;
|
||||
self.push_history(input, cmd, frame_count)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,6 +112,7 @@ pub trait ScaleableFramebuffer<T> {
|
|||
}
|
||||
|
||||
/// Scale framebuffers according to the pass configs, source and viewport size.
|
||||
#[inline(always)]
|
||||
pub fn scale_framebuffers<T, F, E, P>(
|
||||
source_size: Size<u32>,
|
||||
viewport_size: Size<u32>,
|
||||
|
@ -136,6 +137,7 @@ where
|
|||
|
||||
/// Scale framebuffers according to the pass configs, source and viewport size
|
||||
/// passing a context into the scale function and a callback for each framebuffer rescale.
|
||||
#[inline(always)]
|
||||
pub fn scale_framebuffers_with_context_callback<T, F, E, C, P>(
|
||||
source_size: Size<u32>,
|
||||
viewport_size: Size<u32>,
|
||||
|
@ -178,7 +180,7 @@ where
|
|||
|
||||
target_size = next_size;
|
||||
|
||||
callback(index, &pass, &output[index], &feedback[index])?;
|
||||
callback(index, pass, &output[index], &feedback[index])?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
Loading…
Add table
Reference in a new issue