From bb96532ae6867eee043f756ed078933d31d52a92 Mon Sep 17 00:00:00 2001 From: imrn99 <95699343+imrn99@users.noreply.github.com> Date: Fri, 3 May 2024 11:17:19 +0200 Subject: [PATCH] refactor: add default compilation option to the state creation --- honeycomb-render/src/runner.rs | 3 ++- honeycomb-render/src/state.rs | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/honeycomb-render/src/runner.rs b/honeycomb-render/src/runner.rs index 015c42b7..98187e86 100644 --- a/honeycomb-render/src/runner.rs +++ b/honeycomb-render/src/runner.rs @@ -55,7 +55,8 @@ async fn inner( }; // put a hard cap on the rendering speed std::thread::sleep(std::time::Duration::from_millis( - (MS_PER_FRAME - start.elapsed().as_millis()) as u64, + (MS_PER_FRAME.saturating_sub(start.elapsed().as_millis())) + as u64, )); } WindowEvent::CloseRequested => target.exit(), diff --git a/honeycomb-render/src/state.rs b/honeycomb-render/src/state.rs index fe53ad7e..cb41cfc6 100644 --- a/honeycomb-render/src/state.rs +++ b/honeycomb-render/src/state.rs @@ -14,7 +14,7 @@ use honeycomb_core::{CMap2, CoordsFloat}; // extern use std::borrow::Cow; use wgpu::util::DeviceExt; -use wgpu::PrimitiveTopology; +use wgpu::{PipelineCompilationOptions, PrimitiveTopology}; use winit::dpi::PhysicalSize; use winit::event::{ElementState, KeyEvent}; use winit::event_loop::ActiveEventLoop; @@ -194,11 +194,13 @@ async fn inner( module: &shader, entry_point: "vs_main", buffers: &[Coords2Shader::desc()], + compilation_options: PipelineCompilationOptions::default(), }, fragment: Some(wgpu::FragmentState { module: &shader, entry_point: "fs_main", targets: &[Some(swapchain_format.into())], + compilation_options: PipelineCompilationOptions::default(), }), primitive: wgpu::PrimitiveState { topology: PrimitiveTopology::TriangleList,