diff --git a/Cargo.lock b/Cargo.lock index 7a25857..921ea12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -191,9 +191,9 @@ dependencies = [ [[package]] name = "block-sys" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dd7cf50912cddc06dc5ea7c08c5e81c1b2c842a70d19def1848d54c586fed92" +checksum = "ae85a0696e7ea3b835a453750bf002770776609115e6d25c6d2ff28a8200f7e7" dependencies = [ "objc-sys 0.3.2", ] @@ -214,7 +214,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15b55663a85f33501257357e6421bb33e769d5c9ffb5ba0921c975a123e35e68" dependencies = [ - "block-sys 0.2.0", + "block-sys 0.2.1", "objc2 0.4.1", ] @@ -2941,9 +2941,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.5.32" +version = "0.5.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8434aeec7b290e8da5c3f0d628cb0eac6cabcb31d14bb74f779a08109a5914d6" +checksum = "b7520bbdec7211caa7c4e682eb1fbe07abe20cee6756b6e00f537c82c11816aa" dependencies = [ "memchr", ] diff --git a/crates/vent-common/Cargo.toml b/crates/vent-common/Cargo.toml index 827e31b..73c25ac 100644 --- a/crates/vent-common/Cargo.toml +++ b/crates/vent-common/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -winit = "0.29.7" +winit = "0.29.9" sysinfo = "0.30" chrono = "0.4" diff --git a/crates/vent-editor/Cargo.toml b/crates/vent-editor/Cargo.toml index 558747c..d358050 100644 --- a/crates/vent-editor/Cargo.toml +++ b/crates/vent-editor/Cargo.toml @@ -17,7 +17,7 @@ ash = { version= "0.37.3", default-features = false, features = ["linked", "debu egui = "0.24.1" egui_dock = "0.9.1" -winit = "0.29.7" +winit = "0.29.9" pollster = "0.3.0" log = "0.4" diff --git a/crates/vent-rendering/Cargo.toml b/crates/vent-rendering/Cargo.toml index 1ddbf25..02d043c 100644 --- a/crates/vent-rendering/Cargo.toml +++ b/crates/vent-rendering/Cargo.toml @@ -10,7 +10,7 @@ ash = { version= "0.37.3", default-features = false, features = ["linked", "debu image = "0.24.7" -winit = "0.29.7" +winit = "0.29.9" raw-window-handle = "0.6" log = "0.4" diff --git a/crates/vent-rendering/src/instance.rs b/crates/vent-rendering/src/instance.rs index 1d46ecb..b5743d3 100644 --- a/crates/vent-rendering/src/instance.rs +++ b/crates/vent-rendering/src/instance.rs @@ -254,7 +254,6 @@ impl VulkanInstance { pub fn recreate_swap_chain(&mut self, new_size: &PhysicalSize) { unsafe { - self.device.device_wait_idle().unwrap(); let (swapchain, surface_resolution) = Self::create_swapchain( @@ -266,22 +265,26 @@ impl VulkanInstance { *new_size, Some(self.swapchain), ); - // We reuse the old Swapchain and then deleting it + // We reuse the old Swapchain and then deleting it self.clean_swapchain(); self.swapchain = swapchain; self.surface_resolution = surface_resolution; - (self.swapchain_image_views, self.swapchain_images) = Self::create_image_views( &self.device, &self.swapchain_loader, self.swapchain, self.surface_format, ); - + self.depth_image.destroy(&self.device); - self.depth_image = VulkanImage::new_depth(&self.device, &self.memory_allocator, self.depth_format, surface_resolution); + self.depth_image = VulkanImage::new_depth( + &self.device, + &self.memory_allocator, + self.depth_format, + surface_resolution, + ); self.frame_buffers = Self::create_frame_buffers( &self.swapchain_image_views, @@ -321,7 +324,8 @@ impl VulkanInstance { unsafe { self.device - .queue_submit2(self.graphics_queue, &[submit_info], in_flight_fence).unwrap(); + .queue_submit2(self.graphics_queue, &[submit_info], in_flight_fence) + .unwrap(); } let swapchains = &[self.swapchain]; @@ -335,18 +339,18 @@ impl VulkanInstance { self.frame = (self.frame + 1) % MAX_FRAMES_IN_FLIGHT as usize; unsafe { - let result = self.swapchain_loader + let result = self + .swapchain_loader .queue_present(self.present_queue, &present_info); - return result == Err(vk::Result::ERROR_OUT_OF_DATE_KHR) || result == Err(vk::Result::SUBOPTIMAL_KHR); - + result == Err(vk::Result::ERROR_OUT_OF_DATE_KHR) + || result == Err(vk::Result::SUBOPTIMAL_KHR) } } - unsafe fn clean_swapchain(&mut self) { self.frame_buffers - .drain(..) - .for_each(|f| self.device.destroy_framebuffer(f, None)); + .drain(..) + .for_each(|f| self.device.destroy_framebuffer(f, None)); self.swapchain_image_views .drain(..) diff --git a/crates/vent-runtime/Cargo.toml b/crates/vent-runtime/Cargo.toml index c45eab1..0436765 100644 --- a/crates/vent-runtime/Cargo.toml +++ b/crates/vent-runtime/Cargo.toml @@ -13,7 +13,7 @@ vent-ecs = { path = "../vent-ecs"} ash = { version= "0.37.3", default-features = false, features = ["linked", "debug"] } -winit = "0.29.7" +winit = "0.29.9" pollster = "0.3.0" log = "0.4" diff --git a/crates/vent-runtime/res/shaders/app/3D/shader.frag b/crates/vent-runtime/res/shaders/app/3D/shader.frag index 6c2c936..0f52737 100644 --- a/crates/vent-runtime/res/shaders/app/3D/shader.frag +++ b/crates/vent-runtime/res/shaders/app/3D/shader.frag @@ -26,7 +26,7 @@ layout (location = 0) out vec4 fragColor; const float ambient_strength = 0.1; void main() { - vec4 texture = texture(texture_diffuse, tex_coord); + vec4 texture = texture(texture_diffuse, tex_coord) ; // Calculate the ambient color // vec3 ambient_color = light.color * ambient_strength; diff --git a/crates/vent-runtime/src/render/camera/mod.rs b/crates/vent-runtime/src/render/camera/mod.rs index 6bfef70..adac437 100644 --- a/crates/vent-runtime/src/render/camera/mod.rs +++ b/crates/vent-runtime/src/render/camera/mod.rs @@ -79,7 +79,7 @@ impl Camera for Camera3D { fn recreate_projection(&mut self, aspect_ratio: f32) { self.ubo.projection = - glam::Mat4::perspective_rh(self.fovy.to_radians(), aspect_ratio, self.znear, self.zfar); + glam::Mat4::perspective_lh(self.fovy.to_radians(), aspect_ratio, self.znear, self.zfar); } } @@ -87,7 +87,7 @@ impl Camera3D { pub fn update_set() {} pub fn recreate_view(&mut self) { - let view = glam::Mat4::look_at_rh( + let view = glam::Mat4::look_at_lh( self.position, self.position + self.direction(), glam::Vec3::Y, diff --git a/crates/vent-runtime/src/render/d3/light_renderer.rs b/crates/vent-runtime/src/render/d3/light_renderer.rs index 350ae03..f1b406f 100644 --- a/crates/vent-runtime/src/render/d3/light_renderer.rs +++ b/crates/vent-runtime/src/render/d3/light_renderer.rs @@ -3,6 +3,7 @@ use vent_assets::Mesh3D; use crate::render::model_renderer::ModelRenderer3D; +#[repr(C)] pub struct LightUBO { pub position: Vec3, pub color: Vec3, diff --git a/crates/vent-runtime/src/render/d3/mod.rs b/crates/vent-runtime/src/render/d3/mod.rs index 17b8b36..6f00070 100644 --- a/crates/vent-runtime/src/render/d3/mod.rs +++ b/crates/vent-runtime/src/render/d3/mod.rs @@ -1,7 +1,6 @@ use std::mem::size_of; use ash::vk; -use bytemuck::{Pod, Zeroable}; use glam::{Mat4, Vec3, Vec4}; use vent_assets::Mesh3D; @@ -20,6 +19,7 @@ use super::{ pub mod light_renderer; +#[repr(C)] pub struct MaterialUBO { pub base_color: Vec4, }