fmt: clean up unused imports
This commit is contained in:
parent
2450217c29
commit
54e86e7b06
3
Cargo.lock
generated
3
Cargo.lock
generated
|
@ -1953,10 +1953,7 @@ dependencies = [
|
||||||
"librashader-presets 0.2.0-beta.2",
|
"librashader-presets 0.2.0-beta.2",
|
||||||
"librashader-reflect",
|
"librashader-reflect",
|
||||||
"librashader-runtime",
|
"librashader-runtime",
|
||||||
"librashader-spirv-cross",
|
|
||||||
"log",
|
"log",
|
||||||
"once_cell",
|
|
||||||
"parking_lot",
|
|
||||||
"pollster",
|
"pollster",
|
||||||
"raw-window-handle 0.6.0",
|
"raw-window-handle 0.6.0",
|
||||||
"rayon",
|
"rayon",
|
||||||
|
|
|
@ -9,21 +9,16 @@ edition = "2021"
|
||||||
librashader-common = { path = "../librashader-common", features = ["wgpu"], version = "0.2.0-beta.2" }
|
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-presets = { path = "../librashader-presets", version = "0.2.0-beta.2" }
|
||||||
librashader-preprocess = { path = "../librashader-preprocess", 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" }
|
librashader-runtime = { path = "../librashader-runtime" , version = "0.2.0-beta.2" }
|
||||||
|
|
||||||
wgpu = { version = "0.19.0", features = ["spirv"] }
|
wgpu = { version = "0.19.0", features = ["spirv"] }
|
||||||
rustc-hash = "1.1.0"
|
rustc-hash = "1.1.0"
|
||||||
image = "0.24.7"
|
image = "0.24.7"
|
||||||
thiserror = "1.0.50"
|
thiserror = "1.0.50"
|
||||||
spirv_cross = { package = "librashader-spirv-cross", version = "0.23" }
|
|
||||||
parking_lot = "0.12.1"
|
|
||||||
rayon = "1.8.0"
|
rayon = "1.8.0"
|
||||||
bytemuck = { version = "1.14.0", features = ["derive"] }
|
bytemuck = { version = "1.14.0", features = ["derive"] }
|
||||||
|
|
||||||
array-concat = "0.5.2"
|
array-concat = "0.5.2"
|
||||||
config = "0.13.4"
|
|
||||||
once_cell = "1.19.0"
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
config = { version = "0.13.4", features = [] }
|
config = { version = "0.13.4", features = [] }
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use parking_lot::RwLock;
|
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use array_concat::concat_arrays;
|
use array_concat::concat_arrays;
|
||||||
use librashader_runtime::quad::QuadType;
|
use librashader_runtime::quad::QuadType;
|
||||||
use wgpu::util::{BufferInitDescriptor, DeviceExt};
|
use wgpu::util::{BufferInitDescriptor, DeviceExt};
|
||||||
use wgpu::{Buffer, BufferAddress, BufferDescriptor, Device, Maintain, Queue, RenderPass};
|
use wgpu::{Buffer, Device, RenderPass};
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
const VBO_OFFSCREEN: [f32; 16] = [
|
const VBO_OFFSCREEN: [f32; 16] = [
|
||||||
|
|
|
@ -9,8 +9,6 @@ use thiserror::Error;
|
||||||
/// Cumulative error type for WGPU filter chains.
|
/// Cumulative error type for WGPU filter chains.
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum FilterChainError {
|
pub enum FilterChainError {
|
||||||
#[error("SPIRV reflection error")]
|
|
||||||
SpirvCrossReflectError(#[from] spirv_cross::ErrorCode),
|
|
||||||
#[error("shader preset parse error")]
|
#[error("shader preset parse error")]
|
||||||
ShaderPresetError(#[from] ParsePresetError),
|
ShaderPresetError(#[from] ParsePresetError),
|
||||||
#[error("shader preprocess error")]
|
#[error("shader preprocess error")]
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
use librashader_presets::{ShaderPassConfig, ShaderPreset, TextureConfig};
|
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::back::{CompileReflectShader, CompileShader};
|
||||||
use librashader_reflect::front::GlslangCompilation;
|
use librashader_reflect::front::GlslangCompilation;
|
||||||
use librashader_reflect::reflect::presets::{CompilePresetTarget, ShaderPassArtifact};
|
use librashader_reflect::reflect::presets::{CompilePresetTarget, ShaderPassArtifact};
|
||||||
use librashader_reflect::reflect::semantics::ShaderSemantics;
|
use librashader_reflect::reflect::semantics::ShaderSemantics;
|
||||||
use librashader_reflect::reflect::ReflectShader;
|
use librashader_reflect::reflect::ReflectShader;
|
||||||
use librashader_runtime::binding::BindingUtil;
|
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::quad::QuadType;
|
||||||
use librashader_runtime::uniforms::UniformStorage;
|
use librashader_runtime::uniforms::UniformStorage;
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
|
@ -33,7 +33,7 @@ use crate::luts::LutTexture;
|
||||||
use crate::mipmap::MipmapGen;
|
use crate::mipmap::MipmapGen;
|
||||||
use crate::options::FrameOptionsWGPU;
|
use crate::options::FrameOptionsWGPU;
|
||||||
use crate::samplers::SamplerSet;
|
use crate::samplers::SamplerSet;
|
||||||
use crate::texture::{Handle, InputImage, OwnedImage};
|
use crate::texture::{InputImage, OwnedImage};
|
||||||
|
|
||||||
type ShaderPassMeta =
|
type ShaderPassMeta =
|
||||||
ShaderPassArtifact<impl CompileReflectShader<WGSL, GlslangCompilation> + Send>;
|
ShaderPassArtifact<impl CompileReflectShader<WGSL, GlslangCompilation> + Send>;
|
||||||
|
@ -46,7 +46,7 @@ fn compile_passes(
|
||||||
Ok((passes, semantics))
|
Ok((passes, semantics))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A Vulkan filter chain.
|
/// A WGPU filter chain.
|
||||||
pub struct FilterChainWGPU {
|
pub struct FilterChainWGPU {
|
||||||
pub(crate) common: FilterCommon,
|
pub(crate) common: FilterCommon,
|
||||||
passes: Box<[FilterPass]>,
|
passes: Box<[FilterPass]>,
|
||||||
|
@ -54,7 +54,6 @@ pub struct FilterChainWGPU {
|
||||||
feedback_framebuffers: Box<[OwnedImage]>,
|
feedback_framebuffers: Box<[OwnedImage]>,
|
||||||
history_framebuffers: VecDeque<OwnedImage>,
|
history_framebuffers: VecDeque<OwnedImage>,
|
||||||
disable_mipmaps: bool,
|
disable_mipmaps: bool,
|
||||||
// residuals: Box<[FrameResiduals]>,
|
|
||||||
mipmapper: MipmapGen,
|
mipmapper: MipmapGen,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,9 +198,7 @@ impl FilterChainWGPU {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe {
|
back.copy_from(cmd, input);
|
||||||
back.copy_from(cmd, input);
|
|
||||||
}
|
|
||||||
|
|
||||||
self.history_framebuffers.push_front(back)
|
self.history_framebuffers.push_front(back)
|
||||||
}
|
}
|
||||||
|
@ -212,8 +209,6 @@ impl FilterChainWGPU {
|
||||||
passes: Vec<ShaderPassMeta>,
|
passes: Vec<ShaderPassMeta>,
|
||||||
semantics: &ShaderSemantics,
|
semantics: &ShaderSemantics,
|
||||||
) -> error::Result<Box<[FilterPass]>> {
|
) -> error::Result<Box<[FilterPass]>> {
|
||||||
// let frames_in_flight = std::cmp::max(1, frames_in_flight);
|
|
||||||
//
|
|
||||||
let filters: Vec<error::Result<FilterPass>> = passes
|
let filters: Vec<error::Result<FilterPass>> = passes
|
||||||
.into_par_iter()
|
.into_par_iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
|
@ -365,7 +360,7 @@ impl FilterChainWGPU {
|
||||||
source.wrap_mode = pass.config.wrap_mode;
|
source.wrap_mode = pass.config.wrap_mode;
|
||||||
source.mip_filter = pass.config.filter;
|
source.mip_filter = pass.config.filter;
|
||||||
|
|
||||||
let output_image = OutputView::new(target);
|
let output_image = OutputView::from(target);
|
||||||
let out = RenderTarget::identity(&output_image);
|
let out = RenderTarget::identity(&output_image);
|
||||||
|
|
||||||
pass.draw(
|
pass.draw(
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::filter_chain::FilterCommon;
|
||||||
use crate::framebuffer::OutputView;
|
use crate::framebuffer::OutputView;
|
||||||
use crate::graphics_pipeline::WgpuGraphicsPipeline;
|
use crate::graphics_pipeline::WgpuGraphicsPipeline;
|
||||||
use crate::samplers::SamplerSet;
|
use crate::samplers::SamplerSet;
|
||||||
use crate::texture::{InputImage, OwnedImage};
|
use crate::texture::InputImage;
|
||||||
use librashader_common::{ImageFormat, Size, Viewport};
|
use librashader_common::{ImageFormat, Size, Viewport};
|
||||||
use librashader_preprocess::ShaderSource;
|
use librashader_preprocess::ShaderSource;
|
||||||
use librashader_presets::ShaderPassConfig;
|
use librashader_presets::ShaderPassConfig;
|
||||||
|
@ -21,11 +21,7 @@ use librashader_runtime::render_target::RenderTarget;
|
||||||
use librashader_runtime::uniforms::{NoUniformBinder, UniformStorage, UniformStorageAccess};
|
use librashader_runtime::uniforms::{NoUniformBinder, UniformStorage, UniformStorageAccess};
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use wgpu::util::{BufferInitDescriptor, DeviceExt};
|
use wgpu::{BindGroupDescriptor, BindGroupEntry, BindingResource, BufferBinding, ShaderStages};
|
||||||
use wgpu::{
|
|
||||||
BindGroupDescriptor, BindGroupEntry, BindingResource, Buffer, BufferBinding, BufferUsages,
|
|
||||||
RenderPass, ShaderStages, TextureView,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub struct FilterPass {
|
pub struct FilterPass {
|
||||||
pub device: Arc<wgpu::Device>,
|
pub device: Arc<wgpu::Device>,
|
||||||
|
|
|
@ -1,18 +1,44 @@
|
||||||
|
use crate::handle::Handle;
|
||||||
use crate::texture::OwnedImage;
|
use crate::texture::OwnedImage;
|
||||||
use librashader_common::Size;
|
use librashader_common::Size;
|
||||||
|
use wgpu::TextureViewDescriptor;
|
||||||
|
|
||||||
pub struct OutputView<'a> {
|
pub struct OutputView<'a> {
|
||||||
pub size: Size<u32>,
|
pub(crate) size: Size<u32>,
|
||||||
pub view: &'a wgpu::TextureView,
|
pub(crate) view: Handle<'a, wgpu::TextureView>,
|
||||||
pub format: wgpu::TextureFormat,
|
pub(crate) format: wgpu::TextureFormat,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> OutputView<'a> {
|
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 {
|
Self {
|
||||||
size: image.size,
|
size: image.size,
|
||||||
view: &image.view,
|
view: Handle::Borrowed(&image.view),
|
||||||
format: image.image.format(),
|
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(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::framebuffer::OutputView;
|
use crate::framebuffer::OutputView;
|
||||||
use crate::{error, util};
|
use crate::util;
|
||||||
use librashader_reflect::back::wgsl::NagaWgslContext;
|
use librashader_reflect::back::wgsl::NagaWgslContext;
|
||||||
use librashader_reflect::back::ShaderCompilerOutput;
|
use librashader_reflect::back::ShaderCompilerOutput;
|
||||||
use librashader_reflect::reflect::ShaderReflection;
|
use librashader_reflect::reflect::ShaderReflection;
|
||||||
|
@ -7,11 +7,10 @@ use librashader_runtime::render_target::RenderTarget;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use wgpu::{
|
use wgpu::{
|
||||||
BindGroup, BindGroupDescriptor, BindGroupLayout, BindGroupLayoutDescriptor,
|
BindGroupLayout, BindGroupLayoutDescriptor, BindGroupLayoutEntry, BindingType,
|
||||||
BindGroupLayoutEntry, BindingType, BufferBindingType, BufferSize, CommandEncoder, Device,
|
BufferBindingType, BufferSize, CommandEncoder, Operations, PipelineLayout, PushConstantRange,
|
||||||
Operations, PipelineLayout, PushConstantRange, RenderPass, RenderPassColorAttachment,
|
RenderPass, RenderPassColorAttachment, RenderPassDescriptor, SamplerBindingType, ShaderModule,
|
||||||
RenderPassDescriptor, RenderPipelineDescriptor, SamplerBindingType, ShaderModule, ShaderSource,
|
ShaderSource, ShaderStages, TextureFormat, TextureSampleType, TextureViewDimension,
|
||||||
ShaderStages, TextureFormat, TextureSampleType, TextureViewDimension, VertexAttribute,
|
|
||||||
VertexBufferLayout,
|
VertexBufferLayout,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
17
librashader-runtime-wgpu/src/handle.rs
Normal file
17
librashader-runtime-wgpu/src/handle.rs
Normal 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,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,6 +14,7 @@ mod filter_chain;
|
||||||
mod filter_pass;
|
mod filter_pass;
|
||||||
mod framebuffer;
|
mod framebuffer;
|
||||||
mod graphics_pipeline;
|
mod graphics_pipeline;
|
||||||
|
mod handle;
|
||||||
mod luts;
|
mod luts;
|
||||||
mod mipmap;
|
mod mipmap;
|
||||||
mod options;
|
mod options;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use crate::mipmap::MipmapGen;
|
use crate::mipmap::MipmapGen;
|
||||||
use crate::samplers::SamplerSet;
|
use crate::samplers::SamplerSet;
|
||||||
use crate::texture::{Handle, InputImage};
|
use crate::texture::InputImage;
|
||||||
use librashader_common::{Size, WrapMode};
|
use librashader_common::{Size, WrapMode};
|
||||||
use librashader_presets::TextureConfig;
|
use librashader_presets::TextureConfig;
|
||||||
use librashader_runtime::image::{Image, BGRA8};
|
use librashader_runtime::image::Image;
|
||||||
use librashader_runtime::scaling::MipmapSize;
|
use librashader_runtime::scaling::MipmapSize;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use wgpu::TextureDescriptor;
|
use wgpu::TextureDescriptor;
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use crate::error;
|
|
||||||
use librashader_common::{FilterMode, WrapMode};
|
use librashader_common::{FilterMode, WrapMode};
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
use crate::error::FilterChainError;
|
use crate::error::FilterChainError;
|
||||||
use crate::mipmap::MipmapGen;
|
use crate::mipmap::MipmapGen;
|
||||||
use crate::samplers::SamplerSet;
|
|
||||||
use librashader_common::{FilterMode, ImageFormat, Size, WrapMode};
|
use librashader_common::{FilterMode, ImageFormat, Size, WrapMode};
|
||||||
use librashader_presets::Scale2D;
|
use librashader_presets::Scale2D;
|
||||||
use librashader_runtime::scaling::{MipmapSize, ScaleFramebuffer, ViewportSize};
|
use librashader_runtime::scaling::{MipmapSize, ScaleFramebuffer, ViewportSize};
|
||||||
use std::ops::Deref;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use wgpu::{ImageCopyTexture, TextureFormat, TextureView};
|
|
||||||
|
|
||||||
pub struct OwnedImage {
|
pub struct OwnedImage {
|
||||||
device: Arc<wgpu::Device>,
|
device: Arc<wgpu::Device>,
|
||||||
|
@ -17,30 +14,6 @@ pub struct OwnedImage {
|
||||||
pub size: Size<u32>,
|
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)]
|
#[derive(Clone)]
|
||||||
pub struct InputImage {
|
pub struct InputImage {
|
||||||
/// A handle to the `VkImage`.
|
/// A handle to the `VkImage`.
|
||||||
|
|
|
@ -293,11 +293,11 @@ impl<'a> State<'a> {
|
||||||
x: 0.0,
|
x: 0.0,
|
||||||
y: 0.0,
|
y: 0.0,
|
||||||
mvp: None,
|
mvp: None,
|
||||||
output: librashader_runtime_wgpu::OutputView {
|
output: librashader_runtime_wgpu::OutputView::new_from_raw(
|
||||||
size: filter_output.size().into(),
|
&filter_view,
|
||||||
view: &filter_view,
|
filter_output.size().into(),
|
||||||
format: filter_output.format(),
|
filter_output.format(),
|
||||||
},
|
),
|
||||||
},
|
},
|
||||||
&mut encoder,
|
&mut encoder,
|
||||||
self.frame_count,
|
self.frame_count,
|
||||||
|
|
Loading…
Reference in a new issue