From 46776f5bcf489e3cfed9d22629db4b2967c41fcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kro=C5=A1l=C3=A1k?= Date: Sat, 25 Jan 2020 01:45:55 +0100 Subject: [PATCH] Update to 2018 edition --- libportability-gfx/Cargo.toml | 1 + libportability-gfx/src/conv.rs | 10 +++++----- libportability-gfx/src/handle.rs | 7 +++++-- libportability-gfx/src/impls.rs | 28 +++++++++++++------------- libportability-gfx/src/lib.rs | 34 +++++++++++--------------------- libportability-icd/Cargo.toml | 1 + libportability-icd/src/lib.rs | 2 -- libportability/Cargo.toml | 1 + libportability/src/lib.rs | 2 -- 9 files changed, 39 insertions(+), 47 deletions(-) diff --git a/libportability-gfx/Cargo.toml b/libportability-gfx/Cargo.toml index 3b853fc..04c132d 100644 --- a/libportability-gfx/Cargo.toml +++ b/libportability-gfx/Cargo.toml @@ -2,6 +2,7 @@ name = "portability-gfx" publish = false version = "0.1.0" +edition = "2018" authors = [ "Dzmitry Malyshau ", "Joshua Groves ", diff --git a/libportability-gfx/src/conv.rs b/libportability-gfx/src/conv.rs index 669b517..86e8483 100644 --- a/libportability-gfx/src/conv.rs +++ b/libportability-gfx/src/conv.rs @@ -1,5 +1,5 @@ -use hal::{buffer, command, device, format, image, memory, pass, pso, query, window}; -use hal::{pso::PatchSize, pso::Primitive, Features, IndexType, Limits}; +use crate::hal::{buffer, command, device, format, image, memory, pass, pso, query, window}; +use crate::hal::{pso::PatchSize, pso::Primitive, Features, IndexType, Limits}; use std::mem; @@ -258,7 +258,7 @@ fn map_swizzle_component( component: VkComponentSwizzle, identity: format::Component, ) -> format::Component { - use VkComponentSwizzle::*; + use crate::VkComponentSwizzle::*; match component { VK_COMPONENT_SWIZZLE_IDENTITY => identity, @@ -329,7 +329,7 @@ pub fn map_view_kind(ty: VkImageViewType) -> image::ViewKind { } pub fn map_image_layout(layout: VkImageLayout) -> image::Layout { - use hal::image::Layout::*; + use crate::hal::image::Layout::*; match layout { VkImageLayout::VK_IMAGE_LAYOUT_UNDEFINED => Undefined, VkImageLayout::VK_IMAGE_LAYOUT_GENERAL => General, @@ -605,7 +605,7 @@ pub fn map_dependency_flags(dependencies: VkDependencyFlags) -> memory::Dependen } pub fn map_err_device_creation(err: device::CreationError) -> VkResult { - use hal::device::OutOfMemory::{Device, Host}; + use crate::hal::device::OutOfMemory::{Device, Host}; match err { device::CreationError::OutOfMemory(Host) => VkResult::VK_ERROR_OUT_OF_HOST_MEMORY, device::CreationError::OutOfMemory(Device) => VkResult::VK_ERROR_OUT_OF_DEVICE_MEMORY, diff --git a/libportability-gfx/src/handle.rs b/libportability-gfx/src/handle.rs index 02fc02a..1b5f084 100644 --- a/libportability-gfx/src/handle.rs +++ b/libportability-gfx/src/handle.rs @@ -1,13 +1,16 @@ +use crate::VK_NULL_HANDLE; #[cfg(feature = "nightly")] use std::sync::{Arc, Mutex}; use std::{borrow, cmp, fmt, ops}; -use VK_NULL_HANDLE; #[cfg(feature = "nightly")] use gfx_auxil::FastHashMap; use copyless::{BoxAllocation, BoxHelper}; +#[cfg(feature = "nightly")] +use lazy_static::lazy_static; + #[cfg(feature = "nightly")] lazy_static! { static ref REGISTRY: Arc>> = @@ -141,9 +144,9 @@ pub type DispatchHandle = Handle; #[cfg(feature = "dispatch")] mod dispatch { + use crate::VK_NULL_HANDLE; use copyless::{BoxAllocation, BoxHelper}; use std::{borrow, cmp, fmt, ops}; - use VK_NULL_HANDLE; const ICD_LOADER_MAGIC: u64 = 0x01CDC0DE; diff --git a/libportability-gfx/src/impls.rs b/libportability-gfx/src/impls.rs index 2711fe9..114ec90 100644 --- a/libportability-gfx/src/impls.rs +++ b/libportability-gfx/src/impls.rs @@ -1,13 +1,13 @@ -use hal::adapter::PhysicalDevice; -use hal::buffer::IndexBufferView; -use hal::command::CommandBuffer; -use hal::device::{Device, WaitFor}; -use hal::pool::CommandPool as _; -use hal::pso::DescriptorPool; -use hal::queue::{CommandQueue, QueueFamily}; -use hal::window::{PresentMode, Surface, Swapchain as _}; -use hal::{command as com, memory, pass, pso, queue}; -use hal::{Features, Instance}; +use crate::hal::adapter::PhysicalDevice; +use crate::hal::buffer::IndexBufferView; +use crate::hal::command::CommandBuffer; +use crate::hal::device::{Device, WaitFor}; +use crate::hal::pool::CommandPool as _; +use crate::hal::pso::DescriptorPool; +use crate::hal::queue::{CommandQueue, QueueFamily}; +use crate::hal::window::{PresentMode, Surface, Swapchain as _}; +use crate::hal::{command as com, memory, pass, pso, queue}; +use crate::hal::{Features, Instance}; use std::borrow::Cow; #[cfg(feature = "gfx-backend-metal")] @@ -417,7 +417,7 @@ pub extern "C" fn gfxGetPhysicalDeviceProperties( unsafe { mem::transmute(name) } }; - use hal::adapter::DeviceType; + use crate::hal::adapter::DeviceType; let device_type = match adapter.info.device_type { DeviceType::IntegratedGpu => VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU, DeviceType::DiscreteGpu => VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, @@ -3293,7 +3293,7 @@ pub extern "C" fn gfxCreateCommandPool( _pAllocator: *const VkAllocationCallbacks, pCommandPool: *mut VkCommandPool, ) -> VkResult { - use hal::pool::CommandPoolCreateFlags; + use crate::hal::pool::CommandPoolCreateFlags; let info = unsafe { &*pCreateInfo }; let family = queue::QueueFamilyId(info.queueFamilyIndex as _); @@ -3929,7 +3929,7 @@ pub extern "C" fn gfxCmdClearAttachments( let attachments = unsafe { slice::from_raw_parts(pAttachments, attachmentCount as _) } .iter() .map(|at| { - use VkImageAspectFlagBits::*; + use crate::VkImageAspectFlagBits::*; if at.aspectMask & VK_IMAGE_ASPECT_COLOR_BIT as u32 != 0 { com::AttachmentClear::Color { index: at.colorAttachment as _, @@ -4773,7 +4773,7 @@ pub extern "C" fn gfxAcquireNextImageKHR( None => return VkResult::VK_ERROR_OUT_OF_DATE_KHR, }; - use hal::device::OutOfMemory::{Device, Host}; + use crate::hal::device::OutOfMemory::{Device, Host}; match unsafe { raw.acquire_image(timeout, semaphore.as_ref(), fence.as_ref()) } { Ok(frame) => { diff --git a/libportability-gfx/src/lib.rs b/libportability-gfx/src/lib.rs index 8e3d2f3..d42ee57 100644 --- a/libportability-gfx/src/lib.rs +++ b/libportability-gfx/src/lib.rs @@ -5,9 +5,9 @@ #![cfg_attr(feature = "nightly", feature(core_intrinsics))] #[cfg(feature = "gfx-backend-dx11")] -extern crate gfx_backend_dx11 as back; +use gfx_backend_dx11 as back; #[cfg(feature = "gfx-backend-dx12")] -extern crate gfx_backend_dx12 as back; +use gfx_backend_dx12 as back; #[cfg(not(any( feature = "gfx-backend-dx12", feature = "gfx-backend-dx11", @@ -15,27 +15,17 @@ extern crate gfx_backend_dx12 as back; feature = "gfx-backend-vulkan", feature = "gfx-backend-gl", )))] -extern crate gfx_backend_empty as back; +use gfx_backend_empty as back; #[cfg(feature = "gfx-backend-gl")] -extern crate gfx_backend_gl as back; +use gfx_backend_gl as back; #[cfg(feature = "gfx-backend-metal")] -extern crate gfx_backend_metal as back; +use gfx_backend_metal as back; #[cfg(feature = "gfx-backend-vulkan")] -extern crate gfx_backend_vulkan as back; -extern crate gfx_hal as hal; -extern crate smallvec; +use gfx_backend_vulkan as back; +use gfx_hal as hal; -extern crate copyless; -#[macro_use] -extern crate lazy_static; -#[macro_use] -extern crate log; -#[cfg(feature = "env_logger")] -extern crate env_logger; -#[cfg(feature = "nightly")] -extern crate gfx_auxil; -#[cfg(feature = "renderdoc")] -extern crate renderdoc; +use lazy_static::lazy_static; +use log::{error, warn}; mod conv; mod handle; @@ -43,13 +33,13 @@ mod impls; use smallvec::SmallVec; -use back::Backend as B; -use handle::{DispatchHandle, Handle}; +use crate::back::Backend as B; +use crate::handle::{DispatchHandle, Handle}; use std::collections::HashMap; use std::slice; -pub use impls::*; +pub use crate::impls::*; // Vulkan objects pub type VkInstance = Handle; diff --git a/libportability-icd/Cargo.toml b/libportability-icd/Cargo.toml index 1095114..d8aafe9 100644 --- a/libportability-icd/Cargo.toml +++ b/libportability-icd/Cargo.toml @@ -2,6 +2,7 @@ name = "portability-icd" publish = false version = "0.1.0" +edition = "2018" authors = [ "Dzmitry Malyshau ", "Markus Siglreithmaier ", diff --git a/libportability-icd/src/lib.rs b/libportability-icd/src/lib.rs index b1e8bb8..93e4e08 100644 --- a/libportability-icd/src/lib.rs +++ b/libportability-icd/src/lib.rs @@ -1,7 +1,5 @@ #![allow(non_snake_case)] -extern crate portability_gfx; - use portability_gfx::*; use std::ffi::CStr; diff --git a/libportability/Cargo.toml b/libportability/Cargo.toml index a25aac3..366fd0b 100644 --- a/libportability/Cargo.toml +++ b/libportability/Cargo.toml @@ -2,6 +2,7 @@ name = "portability" publish = false version = "0.1.0" +edition = "2018" authors = [ "Dzmitry Malyshau ", "Markus Siglreithmaier ", diff --git a/libportability/src/lib.rs b/libportability/src/lib.rs index 93f94dd..2203088 100644 --- a/libportability/src/lib.rs +++ b/libportability/src/lib.rs @@ -1,7 +1,5 @@ #![allow(non_snake_case)] -extern crate portability_gfx; - use portability_gfx::*; // These are only shims, reexporting the gfx functions with an vk prefix.