From cb7c4676543cd508dfae8d4dcbd9cc8b61b1a94e Mon Sep 17 00:00:00 2001 From: shan Date: Thu, 6 Oct 2022 07:28:05 -0700 Subject: Fixed lint issues & cleaned up some documentation. --- wgpu/src/buffers.rs | 11 ++++------- wgpu/src/lib.rs | 2 +- wgpu/src/shader/triangle_gradient.wgsl | 2 +- wgpu/src/shader/triangle_solid.wgsl | 2 +- wgpu/src/triangle.rs | 2 +- wgpu/src/triangle/gradient.rs | 2 +- 6 files changed, 9 insertions(+), 12 deletions(-) (limited to 'wgpu/src') diff --git a/wgpu/src/buffers.rs b/wgpu/src/buffers.rs index bf7bb49e..7a15692b 100644 --- a/wgpu/src/buffers.rs +++ b/wgpu/src/buffers.rs @@ -9,7 +9,7 @@ use std::mem; const DEFAULT_STATIC_BUFFER_COUNT: wgpu::BufferAddress = 128; /// A generic buffer struct useful for items which have no alignment requirements -/// (e.g. Vertex, Index buffers) and are set once and never changed until destroyed. +/// (e.g. Vertex, Index buffers) & no dynamic offsets. #[derive(Debug)] pub(crate) struct StaticBuffer { //stored sequentially per mesh iteration; refers to the offset index in the GPU buffer @@ -17,7 +17,6 @@ pub(crate) struct StaticBuffer { label: &'static str, usages: wgpu::BufferUsages, gpu: wgpu::Buffer, - //the static size of the buffer size: wgpu::BufferAddress, _data: PhantomData, } @@ -75,11 +74,9 @@ impl StaticBuffer { } } - /// Writes the current vertex data to the gpu buffer if it is currently writable with a memcpy & - /// stores its offset. + /// Writes the current vertex data to the gpu buffer with a memcpy & stores its offset. /// - /// This will return either the offset of the written bytes, or `None` if the GPU buffer is not - /// currently writable. + /// Returns the size of the written bytes. pub fn write( &mut self, device: &wgpu::Device, @@ -125,4 +122,4 @@ impl StaticBuffer { pub fn clear(&mut self) { self.offsets.clear() } -} \ No newline at end of file +} diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index 42cf712e..c76c8c7a 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -41,8 +41,8 @@ pub mod settings; pub mod triangle; pub mod window; -pub mod buffers; +mod buffers; mod backend; mod quad; mod text; diff --git a/wgpu/src/shader/triangle_gradient.wgsl b/wgpu/src/shader/triangle_gradient.wgsl index df7158af..4efda260 100644 --- a/wgpu/src/shader/triangle_gradient.wgsl +++ b/wgpu/src/shader/triangle_gradient.wgsl @@ -85,4 +85,4 @@ fn fs_gradient(input: VertexOutput) -> @location(0) vec4 { } return color; -} \ No newline at end of file +} diff --git a/wgpu/src/shader/triangle_solid.wgsl b/wgpu/src/shader/triangle_solid.wgsl index 126eceaa..be51ebb0 100644 --- a/wgpu/src/shader/triangle_solid.wgsl +++ b/wgpu/src/shader/triangle_solid.wgsl @@ -15,4 +15,4 @@ fn vs_main(@location(0) input: vec2) -> @builtin(position) vec4 { @fragment fn fs_solid() -> @location(0) vec4 { return solid_uniforms.color; -} \ No newline at end of file +} diff --git a/wgpu/src/triangle.rs b/wgpu/src/triangle.rs index a7ad7b77..6e35be3c 100644 --- a/wgpu/src/triangle.rs +++ b/wgpu/src/triangle.rs @@ -26,7 +26,7 @@ pub(crate) struct Pipeline { pipelines: TrianglePipelines, } -/// Supported triangle pipelines for different fills. Both use the same vertex shader. +/// Supported triangle pipelines for different fills. pub(crate) struct TrianglePipelines { solid: SolidPipeline, gradient: GradientPipeline, diff --git a/wgpu/src/triangle/gradient.rs b/wgpu/src/triangle/gradient.rs index b6553708..11c072ca 100644 --- a/wgpu/src/triangle/gradient.rs +++ b/wgpu/src/triangle/gradient.rs @@ -9,7 +9,7 @@ use glam::{IVec4, Vec4}; use iced_graphics::gradient::Gradient; use iced_graphics::Transformation; -pub(super) struct GradientPipeline { +pub struct GradientPipeline { pipeline: wgpu::RenderPipeline, pub(super) uniform_buffer: DynamicBuffer, pub(super) storage_buffer: DynamicBuffer, -- cgit