Pārlūkot izejas kodu

update wgpu and stuff

deltanedas 3 gadi atpakaļ
vecāks
revīzija
16c29e1158

+ 3 - 4
Cargo.toml

@@ -1,6 +1,6 @@
 [package]
 name = "chair"
-version = "0.2.3"
+version = "0.3.0"
 edition = "2021"
 description = "An efficient binary mesh format which is both small and extremely fast to read."
 readme = "README.md"
@@ -12,11 +12,10 @@ keywords = ["mesh"]
 [dependencies]
 bytemuck = {version = "1", features = ["derive"]}
 byteorder = {version = "1", optional = true}
-enumflags2 = "0.7"
+enumflags2 = "0.7.8"
 log = {version = "0.4", optional = true}
-macro_pub = "0.1"
 thiserror = {version = "1", optional = true}
-wgpu = {version = "0.14", optional = true}
+wgpu = {version = "0.18", optional = true}
 
 [features]
 default = ["io", "mesh", "vertex-impls"]

+ 2 - 2
examples/viewer/Cargo.toml

@@ -10,8 +10,8 @@ chair = {path = "../.."}
 env_logger = "0.9"
 image = {version = "0.24", default-features = false, features = ["png"]}
 pollster = "0.2"
-wgpu = "0.14"
-winit = "0.27"
+wgpu = "0.18"
+winit = "0.28" # wgpu using old RWH version
 
 [profile.release]
 strip = true

+ 6 - 6
examples/viewer/src/render/atlas.rs

@@ -1,5 +1,3 @@
-use std::num::NonZeroU32;
-
 use chair::*;
 use wgpu::*;
 
@@ -33,6 +31,7 @@ pub fn load_texture(device: &Device, queue: &Queue, bytes: &[u8]) -> (BindGroup,
 		depth_or_array_layers: 1
 	};
 
+	let format = TextureFormat::Rgba8UnormSrgb;
 	let texture = device.create_texture(&TextureDescriptor {
 		label: Some("Atlas Texture"),
 		size,
@@ -41,9 +40,10 @@ pub fn load_texture(device: &Device, queue: &Queue, bytes: &[u8]) -> (BindGroup,
 		// no MSAA
 		sample_count: 1,
 		dimension: TextureDimension::D2,
-		format: TextureFormat::Rgba8UnormSrgb,
+		format,
 		// use this texture in shaders, copy to it
-		usage: TextureUsages::TEXTURE_BINDING | TextureUsages::COPY_DST
+		usage: TextureUsages::TEXTURE_BINDING | TextureUsages::COPY_DST,
+		view_formats: &[format]
 	});
 
 	// copy texture from host to device memory
@@ -58,8 +58,8 @@ pub fn load_texture(device: &Device, queue: &Queue, bytes: &[u8]) -> (BindGroup,
 		ImageDataLayout {
 			offset: 0,
 			// 4 BPP
-			bytes_per_row: NonZeroU32::new(4 * dimensions.0),
-			rows_per_image: NonZeroU32::new(dimensions.1)
+			bytes_per_row: Some(4 * dimensions.0),
+			rows_per_image: Some(dimensions.1)
 		},
 		size
 	);

+ 2 - 1
examples/viewer/src/render/depth.rs

@@ -20,7 +20,8 @@ impl DepthBuffer {
 			dimension: TextureDimension::D2,
 			format: Self::FORMAT,
 			usage: TextureUsages::RENDER_ATTACHMENT
-				| TextureUsages::TEXTURE_BINDING
+				| TextureUsages::TEXTURE_BINDING,
+			view_formats: &[Self::FORMAT]
 		});
 
 		let view = texture.create_view(&Default::default());

+ 16 - 10
examples/viewer/src/render/renderer.rs

@@ -53,8 +53,9 @@ impl Renderer {
 	pub async fn new(window: &Window, path: &str) -> Self {
 		let size = window.inner_size();
 
-		let instance = Instance::new(Backends::all());
-		let surface = unsafe { instance.create_surface(window) };
+		let instance = Instance::new(InstanceDescriptor::default());
+		let surface = unsafe { instance.create_surface(window) }
+			.expect("Failed to create surface");
 		let adapter = instance.request_adapter(
 			// want to find the fastest gpu first, must support rendering to our surface
 			&RequestAdapterOptions {
@@ -75,16 +76,19 @@ impl Renderer {
 			None // Trace path
 		).await.expect("Failed to find a suitable physical device");
 
+		let caps = surface.get_capabilities(&adapter);
+		let format = *caps.formats
+			.first()
+			.expect("Surface has no preferred format");
 		let config = SurfaceConfiguration {
 			// using the surface to write to the window
 			usage: TextureUsages::RENDER_ATTACHMENT,
-			format: *surface.get_supported_formats(&adapter)
-				.first()
-				.expect("Surface has no preferred format"),
+			format,
 			width: size.width,
 			height: size.height,
 			present_mode: PresentMode::AutoVsync,
-			alpha_mode: CompositeAlphaMode::Auto
+			alpha_mode: CompositeAlphaMode::Auto,
+			view_formats: vec![format]
 		};
 		surface.configure(&device, &config);
 
@@ -229,18 +233,20 @@ impl Renderer {
 						a: 1.0
 					}),
 					// keep what is rendered
-					store: true
+					store: StoreOp::Store
 				}
 			})],
 			// boy thats a mouthful
 			depth_stencil_attachment: Some(RenderPassDepthStencilAttachment {
 				view: &self.depth.view,
 				depth_ops: Some(Operations {
-					load: wgpu::LoadOp::Clear(1.0),
-					store: true
+					load: LoadOp::Clear(1.0),
+					store: StoreOp::Store
 				}),
 				stencil_ops: None
-			})
+			}),
+			timestamp_writes: None,
+			occlusion_query_set: None
 		});
 
 		pass.set_pipeline(&self.mesh_pipeline);

+ 1 - 2
src/features.rs

@@ -1,5 +1,4 @@
 use enumflags2::*;
-use macro_pub::*;
 
 #[bitflags]
 #[repr(u8)]
@@ -18,7 +17,7 @@ pub enum MeshFeature {
 
 pub type MeshFeatures = BitFlags<MeshFeature>;
 
-#[macro_pub]
+#[macro_export]
 macro_rules! features {
 	() => {
 		MeshFeatures::empty()

+ 0 - 6
src/lib.rs

@@ -1,9 +1,3 @@
-#![feature(const_for)]
-#![feature(const_mut_refs)]
-#![feature(decl_macro)]
-// to fix funny bug when `cargo test`ing
-#![feature(rustc_attrs)]
-
 #![allow(clippy::tabs_in_doc_comments)]
 
 //! Efficient binary encoded mesh format

+ 1 - 4
src/vertex/impls.rs

@@ -1,9 +1,6 @@
 //! Some implementations of Vertex that you might find useful
 
-use crate::{
-	features::*,
-	vertex::*
-};
+use crate::*;
 
 use bytemuck::{Pod, Zeroable};
 #[cfg(feature = "mesh")]