rt(vk): update winit in tests

This commit is contained in:
chyyran 2024-02-10 01:48:41 -05:00 committed by Ronny Chan
parent abbec84594
commit 4733831500
3 changed files with 141 additions and 690 deletions

781
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -33,7 +33,7 @@ rayon = "1.6.1"
[dev-dependencies] [dev-dependencies]
num = "0.4.0" num = "0.4.0"
glfw = "0.49.0" glfw = "0.49.0"
winit = "0.27.5" winit = { version = "0.29.10", features = ["rwh_05"] }
raw-window-handle = "0.5" raw-window-handle = "0.5"
ash-window = "0.12.0" ash-window = "0.12.0"

View file

@ -26,7 +26,7 @@ use vulkan_base::VulkanBase;
use librashader_common::Viewport; use librashader_common::Viewport;
use librashader_runtime_vk::options::FrameOptionsVulkan; use librashader_runtime_vk::options::FrameOptionsVulkan;
use winit::event::{ElementState, Event, KeyboardInput, VirtualKeyCode, WindowEvent}; use winit::event::{ElementState, Event, WindowEvent};
use winit::event_loop::{ControlFlow, EventLoop, EventLoopBuilder}; use winit::event_loop::{ControlFlow, EventLoop, EventLoopBuilder};
use winit::platform::windows::EventLoopBuilderExtWindows; use winit::platform::windows::EventLoopBuilderExtWindows;
@ -55,32 +55,29 @@ impl VulkanWindow {
mut filter_chain: FilterChainVulkan, mut filter_chain: FilterChainVulkan,
) { ) {
let mut counter = 0; let mut counter = 0;
event_loop.run(move |event, _, control_flow| match event { event_loop
Event::WindowEvent { event, .. } => match event { .run(|event, target| {
WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit, match event {
WindowEvent::KeyboardInput { input, .. } => match input { Event::WindowEvent {
KeyboardInput { window_id: _,
virtual_keycode, event,
state, } => match event {
.. WindowEvent::Resized(new_size) => {
} => match (virtual_keycode, state) { // On macos the window needs to be redrawn manually after resizing
(Some(VirtualKeyCode::Escape), ElementState::Pressed) => { window.request_redraw();
*control_flow = ControlFlow::Exit
} }
WindowEvent::RedrawRequested => {
VulkanWindow::draw_frame(counter, &vulkan, &mut filter_chain);
counter += 1;
}
WindowEvent::CloseRequested => target.exit(),
_ => {} _ => {}
}, },
}, Event::AboutToWait => window.request_redraw(),
_ => {} _ => {}
}, }
Event::MainEventsCleared => { })
window.request_redraw(); .unwrap();
}
Event::RedrawRequested(_window_id) => {
VulkanWindow::draw_frame(counter, &vulkan, &mut filter_chain);
counter += 1;
}
_ => (),
})
} }
unsafe fn record_command_buffer( unsafe fn record_command_buffer(
@ -405,7 +402,8 @@ pub fn main(vulkan: VulkanBase, filter_chain: FilterChainVulkan) {
let event_loop = EventLoopBuilder::new() let event_loop = EventLoopBuilder::new()
.with_any_thread(true) .with_any_thread(true)
.with_dpi_aware(true) .with_dpi_aware(true)
.build(); .build()
.unwrap();
let window = VulkanWindow::init_window(&event_loop); let window = VulkanWindow::init_window(&event_loop);
let surface = VulkanSurface::new(&vulkan, &window).unwrap(); let surface = VulkanSurface::new(&vulkan, &window).unwrap();