move unsafe

This commit is contained in:
Alex Janka 2023-10-02 18:43:49 +11:00
parent fa501247ad
commit 520d2e148b

View file

@ -52,15 +52,15 @@ impl WindowData {
}
pub fn resize(&mut self, width: u32, height: u32, factor: u32, window: &Window) {
self.inner.resize(width, height, factor, window);
unsafe { self.inner.resize(width, height, factor, window) };
}
pub fn new_frame(&mut self, buffer: &[[u8; 4]]) {
self.inner.new_frame(buffer);
unsafe { self.inner.new_frame(buffer) };
}
pub fn render(&mut self) {
self.inner.render();
unsafe { self.inner.render() };
}
}
@ -838,12 +838,11 @@ impl VulkanWindowInner {
}
}
fn resize(&mut self, _width: u32, _height: u32, factor: u32, window: &Window) {
*self = unsafe { Self::new(factor, window) };
unsafe fn resize(&mut self, _width: u32, _height: u32, factor: u32, window: &Window) {
*self = Self::new(factor, window);
}
fn new_frame(&mut self, buffer: &[[u8; 4]]) {
unsafe {
unsafe fn new_frame(&mut self, buffer: &[[u8; 4]]) {
let image_ptr = self
.device
.map_memory(
@ -939,10 +938,8 @@ impl VulkanWindowInner {
},
);
}
}
fn render(&mut self) {
unsafe {
unsafe fn render(&mut self) {
let (present_index, _) = self
.swapchain_loader
.acquire_next_image(
@ -1017,7 +1014,6 @@ impl VulkanWindowInner {
.unwrap();
}
}
}
impl Drop for VulkanWindowInner {
fn drop(&mut self) {
@ -1073,7 +1069,7 @@ impl Drop for VulkanWindowInner {
}
#[allow(clippy::too_many_arguments)]
fn record_submit_commandbuffer<F: FnOnce(&Device, vk::CommandBuffer)>(
unsafe fn record_submit_commandbuffer<F: FnOnce(&Device, vk::CommandBuffer)>(
device: &Device,
command_buffer: vk::CommandBuffer,
command_buffer_reuse_fence: vk::Fence,
@ -1083,7 +1079,6 @@ fn record_submit_commandbuffer<F: FnOnce(&Device, vk::CommandBuffer)>(
signal_semaphores: &[vk::Semaphore],
f: F,
) {
unsafe {
device
.wait_for_fences(&[command_buffer_reuse_fence], true, std::u64::MAX)
.expect("Wait for fence failed.");
@ -1124,7 +1119,6 @@ fn record_submit_commandbuffer<F: FnOnce(&Device, vk::CommandBuffer)>(
.queue_submit(submit_queue, &[submit_info], command_buffer_reuse_fence)
.expect("queue submit failed.");
}
}
fn find_memorytype_index(
memory_req: &vk::MemoryRequirements,