fmt: clean up unused imports

This commit is contained in:
chyyran 2024-02-06 01:45:31 -05:00 committed by Ronny Chan
parent 2450217c29
commit 54e86e7b06
15 changed files with 71 additions and 76 deletions

3
Cargo.lock generated
View file

@ -1953,10 +1953,7 @@ dependencies = [
"librashader-presets 0.2.0-beta.2",
"librashader-reflect",
"librashader-runtime",
"librashader-spirv-cross",
"log",
"once_cell",
"parking_lot",
"pollster",
"raw-window-handle 0.6.0",
"rayon",

View file

@ -9,21 +9,16 @@ edition = "2021"
librashader-common = { path = "../librashader-common", features = ["wgpu"], version = "0.2.0-beta.2" }
librashader-presets = { path = "../librashader-presets", version = "0.2.0-beta.2" }
librashader-preprocess = { path = "../librashader-preprocess", version = "0.2.0-beta.2" }
librashader-reflect = { path = "../librashader-reflect", version = "0.2.0-beta.2", features = [] }
librashader-reflect = { path = "../librashader-reflect", version = "0.2.0-beta.2", features = ["wgsl"], default-features = false }
librashader-runtime = { path = "../librashader-runtime" , version = "0.2.0-beta.2" }
wgpu = { version = "0.19.0", features = ["spirv"] }
rustc-hash = "1.1.0"
image = "0.24.7"
thiserror = "1.0.50"
spirv_cross = { package = "librashader-spirv-cross", version = "0.23" }
parking_lot = "0.12.1"
rayon = "1.8.0"
bytemuck = { version = "1.14.0", features = ["derive"] }
array-concat = "0.5.2"
config = "0.13.4"
once_cell = "1.19.0"
[dev-dependencies]
config = { version = "0.13.4", features = [] }

View file

@ -1,4 +1,3 @@
use parking_lot::RwLock;
use std::ops::{Deref, DerefMut};
use std::sync::Arc;

View file

@ -1,7 +1,7 @@
use array_concat::concat_arrays;
use librashader_runtime::quad::QuadType;
use wgpu::util::{BufferInitDescriptor, DeviceExt};
use wgpu::{Buffer, BufferAddress, BufferDescriptor, Device, Maintain, Queue, RenderPass};
use wgpu::{Buffer, Device, RenderPass};
#[rustfmt::skip]
const VBO_OFFSCREEN: [f32; 16] = [

View file

@ -9,8 +9,6 @@ use thiserror::Error;
/// Cumulative error type for WGPU filter chains.
#[derive(Error, Debug)]
pub enum FilterChainError {
#[error("SPIRV reflection error")]
SpirvCrossReflectError(#[from] spirv_cross::ErrorCode),
#[error("shader preset parse error")]
ShaderPresetError(#[from] ParsePresetError),
#[error("shader preprocess error")]

View file

@ -1,12 +1,12 @@
use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig};
use librashader_reflect::back::targets::{SPIRV, WGSL};
use librashader_reflect::back::targets::WGSL;
use librashader_reflect::back::{CompileReflectShader, CompileShader};
use librashader_reflect::front::GlslangCompilation;
use librashader_reflect::reflect::presets::{CompilePresetTarget, ShaderPassArtifact};
use librashader_reflect::reflect::semantics::ShaderSemantics;
use librashader_reflect::reflect::ReflectShader;
use librashader_runtime::binding::BindingUtil;
use librashader_runtime::image::{Image, ImageError, UVDirection, BGRA8, RGBA8};
use librashader_runtime::image::{Image, ImageError, UVDirection};
use librashader_runtime::quad::QuadType;
use librashader_runtime::uniforms::UniformStorage;
use rustc_hash::FxHashMap;
@ -33,7 +33,7 @@ use crate::luts::LutTexture;
use crate::mipmap::MipmapGen;
use crate::options::FrameOptionsWGPU;
use crate::samplers::SamplerSet;
use crate::texture::{Handle, InputImage, OwnedImage};
use crate::texture::{InputImage, OwnedImage};
type ShaderPassMeta =
ShaderPassArtifact<impl CompileReflectShader<WGSL, GlslangCompilation> + Send>;
@ -46,7 +46,7 @@ fn compile_passes(
Ok((passes, semantics))
}
/// A Vulkan filter chain.
/// A WGPU filter chain.
pub struct FilterChainWGPU {
pub(crate) common: FilterCommon,
passes: Box<[FilterPass]>,
@ -54,7 +54,6 @@ pub struct FilterChainWGPU {
feedback_framebuffers: Box<[OwnedImage]>,
history_framebuffers: VecDeque<OwnedImage>,
disable_mipmaps: bool,
// residuals: Box<[FrameResiduals]>,
mipmapper: MipmapGen,
}
@ -199,9 +198,7 @@ impl FilterChainWGPU {
);
}
unsafe {
back.copy_from(cmd, input);
}
self.history_framebuffers.push_front(back)
}
@ -212,8 +209,6 @@ impl FilterChainWGPU {
passes: Vec<ShaderPassMeta>,
semantics: &ShaderSemantics,
) -> error::Result<Box<[FilterPass]>> {
// let frames_in_flight = std::cmp::max(1, frames_in_flight);
//
let filters: Vec<error::Result<FilterPass>> = passes
.into_par_iter()
.enumerate()
@ -365,7 +360,7 @@ impl FilterChainWGPU {
source.wrap_mode = pass.config.wrap_mode;
source.mip_filter = pass.config.filter;
let output_image = OutputView::new(target);
let output_image = OutputView::from(target);
let out = RenderTarget::identity(&output_image);
pass.draw(

View file

@ -4,7 +4,7 @@ use crate::filter_chain::FilterCommon;
use crate::framebuffer::OutputView;
use crate::graphics_pipeline::WgpuGraphicsPipeline;
use crate::samplers::SamplerSet;
use crate::texture::{InputImage, OwnedImage};
use crate::texture::InputImage;
use librashader_common::{ImageFormat, Size, Viewport};
use librashader_preprocess::ShaderSource;
use librashader_presets::ShaderPassConfig;
@ -21,11 +21,7 @@ use librashader_runtime::render_target::RenderTarget;
use librashader_runtime::uniforms::{NoUniformBinder, UniformStorage, UniformStorageAccess};
use rustc_hash::FxHashMap;
use std::sync::Arc;
use wgpu::util::{BufferInitDescriptor, DeviceExt};
use wgpu::{
BindGroupDescriptor, BindGroupEntry, BindingResource, Buffer, BufferBinding, BufferUsages,
RenderPass, ShaderStages, TextureView,
};
use wgpu::{BindGroupDescriptor, BindGroupEntry, BindingResource, BufferBinding, ShaderStages};
pub struct FilterPass {
pub device: Arc<wgpu::Device>,

View file

@ -1,18 +1,44 @@
use crate::handle::Handle;
use crate::texture::OwnedImage;
use librashader_common::Size;
use wgpu::TextureViewDescriptor;
pub struct OutputView<'a> {
pub size: Size<u32>,
pub view: &'a wgpu::TextureView,
pub format: wgpu::TextureFormat,
pub(crate) size: Size<u32>,
pub(crate) view: Handle<'a, wgpu::TextureView>,
pub(crate) format: wgpu::TextureFormat,
}
impl<'a> OutputView<'a> {
pub fn new(image: &'a OwnedImage) -> Self {
pub fn new_from_raw(
view: &'a wgpu::TextureView,
size: Size<u32>,
format: wgpu::TextureFormat,
) -> Self {
Self {
size,
view: Handle::Borrowed(&view),
format,
}
}
}
impl<'a> From<&'a OwnedImage> for OutputView<'a> {
fn from(image: &'a OwnedImage) -> Self {
Self {
size: image.size,
view: &image.view,
view: Handle::Borrowed(&image.view),
format: image.image.format(),
}
}
}
impl From<&wgpu::Texture> for OutputView<'static> {
fn from(image: &wgpu::Texture) -> Self {
Self {
size: image.size().into(),
view: Handle::Owned(image.create_view(&TextureViewDescriptor::default())),
format: image.format(),
}
}
}

View file

@ -1,5 +1,5 @@
use crate::framebuffer::OutputView;
use crate::{error, util};
use crate::util;
use librashader_reflect::back::wgsl::NagaWgslContext;
use librashader_reflect::back::ShaderCompilerOutput;
use librashader_reflect::reflect::ShaderReflection;
@ -7,11 +7,10 @@ use librashader_runtime::render_target::RenderTarget;
use std::borrow::Cow;
use std::sync::Arc;
use wgpu::{
BindGroup, BindGroupDescriptor, BindGroupLayout, BindGroupLayoutDescriptor,
BindGroupLayoutEntry, BindingType, BufferBindingType, BufferSize, CommandEncoder, Device,
Operations, PipelineLayout, PushConstantRange, RenderPass, RenderPassColorAttachment,
RenderPassDescriptor, RenderPipelineDescriptor, SamplerBindingType, ShaderModule, ShaderSource,
ShaderStages, TextureFormat, TextureSampleType, TextureViewDimension, VertexAttribute,
BindGroupLayout, BindGroupLayoutDescriptor, BindGroupLayoutEntry, BindingType,
BufferBindingType, BufferSize, CommandEncoder, Operations, PipelineLayout, PushConstantRange,
RenderPass, RenderPassColorAttachment, RenderPassDescriptor, SamplerBindingType, ShaderModule,
ShaderSource, ShaderStages, TextureFormat, TextureSampleType, TextureViewDimension,
VertexBufferLayout,
};

View file

@ -0,0 +1,17 @@
use std::ops::Deref;
pub enum Handle<'a, T> {
Borrowed(&'a T),
Owned(T),
}
impl<T> Deref for Handle<'_, T> {
type Target = T;
fn deref(&self) -> &Self::Target {
match self {
Handle::Borrowed(r) => &r,
Handle::Owned(r) => &r,
}
}
}

View file

@ -14,6 +14,7 @@ mod filter_chain;
mod filter_pass;
mod framebuffer;
mod graphics_pipeline;
mod handle;
mod luts;
mod mipmap;
mod options;

View file

@ -1,9 +1,9 @@
use crate::mipmap::MipmapGen;
use crate::samplers::SamplerSet;
use crate::texture::{Handle, InputImage};
use crate::texture::InputImage;
use librashader_common::{Size, WrapMode};
use librashader_presets::TextureConfig;
use librashader_runtime::image::{Image, BGRA8};
use librashader_runtime::image::Image;
use librashader_runtime::scaling::MipmapSize;
use std::sync::Arc;
use wgpu::TextureDescriptor;

View file

@ -1,4 +1,3 @@
use crate::error;
use librashader_common::{FilterMode, WrapMode};
use rustc_hash::FxHashMap;
use std::sync::Arc;

View file

@ -1,12 +1,9 @@
use crate::error::FilterChainError;
use crate::mipmap::MipmapGen;
use crate::samplers::SamplerSet;
use librashader_common::{FilterMode, ImageFormat, Size, WrapMode};
use librashader_presets::Scale2D;
use librashader_runtime::scaling::{MipmapSize, ScaleFramebuffer, ViewportSize};
use std::ops::Deref;
use std::sync::Arc;
use wgpu::{ImageCopyTexture, TextureFormat, TextureView};
pub struct OwnedImage {
device: Arc<wgpu::Device>,
@ -17,30 +14,6 @@ pub struct OwnedImage {
pub size: Size<u32>,
}
pub enum Handle<'a, T> {
Borrowed(&'a T),
Owned(Arc<T>),
}
impl<T> Clone for Handle<'_, T> {
fn clone(&self) -> Self {
match self {
Handle::Borrowed(r) => Handle::Borrowed(r),
Handle::Owned(r) => Handle::Owned(Arc::clone(r)),
}
}
}
impl<T> Deref for Handle<'_, T> {
type Target = T;
fn deref(&self) -> &Self::Target {
match self {
Handle::Borrowed(r) => &r,
Handle::Owned(r) => &r,
}
}
}
#[derive(Clone)]
pub struct InputImage {
/// A handle to the `VkImage`.

View file

@ -293,11 +293,11 @@ impl<'a> State<'a> {
x: 0.0,
y: 0.0,
mvp: None,
output: librashader_runtime_wgpu::OutputView {
size: filter_output.size().into(),
view: &filter_view,
format: filter_output.format(),
},
output: librashader_runtime_wgpu::OutputView::new_from_raw(
&filter_view,
filter_output.size().into(),
filter_output.format(),
),
},
&mut encoder,
self.frame_count,