From 365f37a3ae10e7aff407b84050f77da10820866e Mon Sep 17 00:00:00 2001 From: bungoboingo Date: Thu, 10 Nov 2022 14:43:38 -0800 Subject: Added conditional configurations for WASM target for gradients & storage buffers, since storage buffers are not supported on wgpu WASM target at the moment. --- wgpu/src/buffer/dynamic.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'wgpu/src/buffer/dynamic.rs') diff --git a/wgpu/src/buffer/dynamic.rs b/wgpu/src/buffer/dynamic.rs index c0c48c74..2a675d81 100644 --- a/wgpu/src/buffer/dynamic.rs +++ b/wgpu/src/buffer/dynamic.rs @@ -24,6 +24,7 @@ impl Buffer { ) } + #[cfg(not(target_arch = "wasm32"))] /// Creates a new dynamic storage buffer. pub fn storage(device: &wgpu::Device, label: &'static str) -> Self { Buffer::new( @@ -91,6 +92,7 @@ impl Buffer { Internal::Uniform(_) => { wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST } + #[cfg(not(target_arch = "wasm32"))] Internal::Storage(_) => { wgpu::BufferUsages::STORAGE | wgpu::BufferUsages::COPY_DST } @@ -154,6 +156,8 @@ impl Buffer { // Currently supported dynamic buffers. enum Internal { Uniform(encase::DynamicUniformBuffer>), + #[cfg(not(target_arch = "wasm32"))] + //storage buffers are not supported on wgpu wasm target (yet) Storage(encase::DynamicStorageBuffer>), } @@ -168,6 +172,7 @@ impl Internal { .write(value) .expect("Error when writing to dynamic uniform buffer.") as u32, + #[cfg(not(target_arch = "wasm32"))] Internal::Storage(buf) => buf .write(value) .expect("Error when writing to dynamic storage buffer.") @@ -179,6 +184,7 @@ impl Internal { pub(super) fn get_ref(&self) -> &Vec { match self { Internal::Uniform(buf) => buf.as_ref(), + #[cfg(not(target_arch = "wasm32"))] Internal::Storage(buf) => buf.as_ref(), } } @@ -190,6 +196,7 @@ impl Internal { buf.as_mut().clear(); buf.set_offset(0); } + #[cfg(not(target_arch = "wasm32"))] Internal::Storage(buf) => { buf.as_mut().clear(); buf.set_offset(0); -- cgit From 33c3c0c0aa774bb7462e3c42aa04c591a66376a7 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 14 Nov 2022 00:02:42 +0100 Subject: Group all solid triangles independently of color --- wgpu/src/buffer/dynamic.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'wgpu/src/buffer/dynamic.rs') diff --git a/wgpu/src/buffer/dynamic.rs b/wgpu/src/buffer/dynamic.rs index 2a675d81..18be03dd 100644 --- a/wgpu/src/buffer/dynamic.rs +++ b/wgpu/src/buffer/dynamic.rs @@ -1,10 +1,13 @@ //! Utilities for uniform buffer operations. use encase::private::WriteInto; use encase::ShaderType; + +use std::fmt; use std::marker::PhantomData; /// A dynamic buffer is any type of buffer which does not have a static offset. -pub(crate) struct Buffer { +#[derive(Debug)] +pub struct Buffer { offsets: Vec, cpu: Internal, gpu: wgpu::Buffer, @@ -204,3 +207,13 @@ impl Internal { } } } + +impl fmt::Debug for Internal { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::Uniform(_) => write!(f, "Internal::Uniform(_)"), + #[cfg(not(target_arch = "wasm32"))] + Self::Storage(_) => write!(f, "Internal::Storage(_)"), + } + } +} -- cgit