Rustfmt stable pass

This commit is contained in:
Dzmitry Malyshau committed 2020-04-06 08:55:39 -04:00
1 parent 384606f2e2
commit a3aefe2535
29 files changed
+875 -1066

No files matched your search

+1 -6
View File
@@ -4,14 +4,10 @@
use crate::GLOBAL;
pub use core::command::{
compute_ffi::*,
render_ffi::*,
};
pub use core::command::{compute_ffi::*, render_ffi::*};
use core::{gfx_select, id};
#[no_mangle]
pub extern "C" fn wgpu_command_encoder_finish(
encoder_id: id::CommandEncoderId,
@@ -80,7 +76,6 @@ pub extern "C" fn wgpu_command_encoder_copy_texture_to_texture(
copy_size))
}
/// # Safety
///
/// This function is unsafe because improper use may lead to memory
+17 -28
View File
@@ -4,8 +4,8 @@
use crate::GLOBAL;
use wgt::{BackendBit, DeviceDescriptor, Limits};
use core::{gfx_select, hub::Token, id};
use wgt::{BackendBit, DeviceDescriptor, Limits};
use std::{marker::PhantomData, slice};
@@ -30,13 +30,12 @@ pub fn wgpu_create_surface(raw_handle: raw_window_handle::RawWindowHandle) -> id
},
#[cfg(target_os = "macos")]
Rwh::MacOS(h) => {
let ns_view =
if h.ns_view.is_null() {
let ns_window = h.ns_window as *mut Object;
unsafe { msg_send![ns_window, contentView] }
} else {
h.ns_view
};
let ns_view = if h.ns_view.is_null() {
let ns_window = h.ns_window as *mut Object;
unsafe { msg_send![ns_window, contentView] }
} else {
h.ns_view
};
core::instance::Surface {
#[cfg(feature = "vulkan-portability")]
vulkan: instance
@@ -47,7 +46,7 @@ pub fn wgpu_create_surface(raw_handle: raw_window_handle::RawWindowHandle) -> id
.metal
.create_surface_from_nsview(ns_view, cfg!(debug_assertions)),
}
},
}
#[cfg(all(unix, not(target_os = "ios"), not(target_os = "macos")))]
Rwh::Xlib(h) => core::instance::Surface {
vulkan: instance
@@ -105,7 +104,8 @@ pub extern "C" fn wgpu_create_surface_from_wayland(
) -> id::SurfaceId {
use raw_window_handle::unix::WaylandHandle;
wgpu_create_surface(raw_window_handle::RawWindowHandle::Wayland(WaylandHandle {
surface, display,
surface,
display,
..WaylandHandle::empty()
}))
}
@@ -184,10 +184,7 @@ pub extern "C" fn wgpu_adapter_destroy(adapter_id: id::AdapterId) {
}
#[no_mangle]
pub extern "C" fn wgpu_device_get_limits(
_device_id: id::DeviceId,
limits: &mut Limits,
) {
pub extern "C" fn wgpu_device_get_limits(_device_id: id::DeviceId, limits: &mut Limits) {
*limits = Limits::default(); // TODO
}
@@ -209,7 +206,8 @@ pub unsafe extern "C" fn wgpu_device_create_buffer_mapped(
desc: &wgt::BufferDescriptor,
mapped_ptr_out: *mut *mut u8,
) -> id::BufferId {
let (id, ptr) = gfx_select!(device_id => GLOBAL.device_create_buffer_mapped(device_id, desc, PhantomData));
let (id, ptr) =
gfx_select!(device_id => GLOBAL.device_create_buffer_mapped(device_id, desc, PhantomData));
*mapped_ptr_out = ptr;
id
}
@@ -329,8 +327,7 @@ pub unsafe extern "C" fn wgpu_queue_submit(
command_buffers: *const id::CommandBufferId,
command_buffers_length: usize,
) {
let command_buffer_ids =
slice::from_raw_parts(command_buffers, command_buffers_length);
let command_buffer_ids = slice::from_raw_parts(command_buffers, command_buffers_length);
gfx_select!(queue_id => GLOBAL.queue_submit(queue_id, command_buffer_ids))
}
@@ -377,10 +374,7 @@ pub extern "C" fn wgpu_buffer_map_read_async(
callback: core::device::BufferMapReadCallback,
userdata: *mut u8,
) {
let operation = core::resource::BufferMapOperation::Read {
callback,
userdata,
};
let operation = core::resource::BufferMapOperation::Read { callback, userdata };
gfx_select!(buffer_id => GLOBAL.buffer_map_async(buffer_id, wgt::BufferUsage::MAP_READ, start .. start + size, operation))
}
@@ -393,10 +387,7 @@ pub extern "C" fn wgpu_buffer_map_write_async(
callback: core::device::BufferMapWriteCallback,
userdata: *mut u8,
) {
let operation = core::resource::BufferMapOperation::Write {
callback,
userdata,
};
let operation = core::resource::BufferMapOperation::Write { callback, userdata };
gfx_select!(buffer_id => GLOBAL.buffer_map_async(buffer_id, wgt::BufferUsage::MAP_WRITE, start .. start + size, operation))
}
@@ -411,9 +402,7 @@ pub extern "C" fn wgpu_swap_chain_get_next_texture(
swap_chain_id: id::SwapChainId,
) -> core::swap_chain::SwapChainOutput {
gfx_select!(swap_chain_id => GLOBAL.swap_chain_get_next_texture(swap_chain_id, PhantomData))
.unwrap_or(core::swap_chain::SwapChainOutput {
view_id: None,
})
.unwrap_or(core::swap_chain::SwapChainOutput { view_id: None })
}
#[no_mangle]