Update to 2018 edition

This commit is contained in:
Martin Krošlák 2020-01-25 01:45:55 +01:00
parent 4958223f8e
commit 46776f5bcf
9 changed files with 39 additions and 47 deletions

View file

@ -2,6 +2,7 @@
name = "portability-gfx" name = "portability-gfx"
publish = false publish = false
version = "0.1.0" version = "0.1.0"
edition = "2018"
authors = [ authors = [
"Dzmitry Malyshau <kvark@mozilla.com>", "Dzmitry Malyshau <kvark@mozilla.com>",
"Joshua Groves <josh@joshgroves.com>", "Joshua Groves <josh@joshgroves.com>",

View file

@ -1,5 +1,5 @@
use hal::{buffer, command, device, format, image, memory, pass, pso, query, window}; use crate::hal::{buffer, command, device, format, image, memory, pass, pso, query, window};
use hal::{pso::PatchSize, pso::Primitive, Features, IndexType, Limits}; use crate::hal::{pso::PatchSize, pso::Primitive, Features, IndexType, Limits};
use std::mem; use std::mem;
@ -258,7 +258,7 @@ fn map_swizzle_component(
component: VkComponentSwizzle, component: VkComponentSwizzle,
identity: format::Component, identity: format::Component,
) -> format::Component { ) -> format::Component {
use VkComponentSwizzle::*; use crate::VkComponentSwizzle::*;
match component { match component {
VK_COMPONENT_SWIZZLE_IDENTITY => identity, 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 { pub fn map_image_layout(layout: VkImageLayout) -> image::Layout {
use hal::image::Layout::*; use crate::hal::image::Layout::*;
match layout { match layout {
VkImageLayout::VK_IMAGE_LAYOUT_UNDEFINED => Undefined, VkImageLayout::VK_IMAGE_LAYOUT_UNDEFINED => Undefined,
VkImageLayout::VK_IMAGE_LAYOUT_GENERAL => General, 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 { 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 { match err {
device::CreationError::OutOfMemory(Host) => VkResult::VK_ERROR_OUT_OF_HOST_MEMORY, device::CreationError::OutOfMemory(Host) => VkResult::VK_ERROR_OUT_OF_HOST_MEMORY,
device::CreationError::OutOfMemory(Device) => VkResult::VK_ERROR_OUT_OF_DEVICE_MEMORY, device::CreationError::OutOfMemory(Device) => VkResult::VK_ERROR_OUT_OF_DEVICE_MEMORY,

View file

@ -1,13 +1,16 @@
use crate::VK_NULL_HANDLE;
#[cfg(feature = "nightly")] #[cfg(feature = "nightly")]
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::{borrow, cmp, fmt, ops}; use std::{borrow, cmp, fmt, ops};
use VK_NULL_HANDLE;
#[cfg(feature = "nightly")] #[cfg(feature = "nightly")]
use gfx_auxil::FastHashMap; use gfx_auxil::FastHashMap;
use copyless::{BoxAllocation, BoxHelper}; use copyless::{BoxAllocation, BoxHelper};
#[cfg(feature = "nightly")]
use lazy_static::lazy_static;
#[cfg(feature = "nightly")] #[cfg(feature = "nightly")]
lazy_static! { lazy_static! {
static ref REGISTRY: Arc<Mutex<FastHashMap<usize, &'static str>>> = static ref REGISTRY: Arc<Mutex<FastHashMap<usize, &'static str>>> =
@ -141,9 +144,9 @@ pub type DispatchHandle<T> = Handle<T>;
#[cfg(feature = "dispatch")] #[cfg(feature = "dispatch")]
mod dispatch { mod dispatch {
use crate::VK_NULL_HANDLE;
use copyless::{BoxAllocation, BoxHelper}; use copyless::{BoxAllocation, BoxHelper};
use std::{borrow, cmp, fmt, ops}; use std::{borrow, cmp, fmt, ops};
use VK_NULL_HANDLE;
const ICD_LOADER_MAGIC: u64 = 0x01CDC0DE; const ICD_LOADER_MAGIC: u64 = 0x01CDC0DE;

View file

@ -1,13 +1,13 @@
use hal::adapter::PhysicalDevice; use crate::hal::adapter::PhysicalDevice;
use hal::buffer::IndexBufferView; use crate::hal::buffer::IndexBufferView;
use hal::command::CommandBuffer; use crate::hal::command::CommandBuffer;
use hal::device::{Device, WaitFor}; use crate::hal::device::{Device, WaitFor};
use hal::pool::CommandPool as _; use crate::hal::pool::CommandPool as _;
use hal::pso::DescriptorPool; use crate::hal::pso::DescriptorPool;
use hal::queue::{CommandQueue, QueueFamily}; use crate::hal::queue::{CommandQueue, QueueFamily};
use hal::window::{PresentMode, Surface, Swapchain as _}; use crate::hal::window::{PresentMode, Surface, Swapchain as _};
use hal::{command as com, memory, pass, pso, queue}; use crate::hal::{command as com, memory, pass, pso, queue};
use hal::{Features, Instance}; use crate::hal::{Features, Instance};
use std::borrow::Cow; use std::borrow::Cow;
#[cfg(feature = "gfx-backend-metal")] #[cfg(feature = "gfx-backend-metal")]
@ -417,7 +417,7 @@ pub extern "C" fn gfxGetPhysicalDeviceProperties(
unsafe { mem::transmute(name) } unsafe { mem::transmute(name) }
}; };
use hal::adapter::DeviceType; use crate::hal::adapter::DeviceType;
let device_type = match adapter.info.device_type { let device_type = match adapter.info.device_type {
DeviceType::IntegratedGpu => VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU, DeviceType::IntegratedGpu => VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU,
DeviceType::DiscreteGpu => VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, DeviceType::DiscreteGpu => VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU,
@ -3293,7 +3293,7 @@ pub extern "C" fn gfxCreateCommandPool(
_pAllocator: *const VkAllocationCallbacks, _pAllocator: *const VkAllocationCallbacks,
pCommandPool: *mut VkCommandPool, pCommandPool: *mut VkCommandPool,
) -> VkResult { ) -> VkResult {
use hal::pool::CommandPoolCreateFlags; use crate::hal::pool::CommandPoolCreateFlags;
let info = unsafe { &*pCreateInfo }; let info = unsafe { &*pCreateInfo };
let family = queue::QueueFamilyId(info.queueFamilyIndex as _); 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 _) } let attachments = unsafe { slice::from_raw_parts(pAttachments, attachmentCount as _) }
.iter() .iter()
.map(|at| { .map(|at| {
use VkImageAspectFlagBits::*; use crate::VkImageAspectFlagBits::*;
if at.aspectMask & VK_IMAGE_ASPECT_COLOR_BIT as u32 != 0 { if at.aspectMask & VK_IMAGE_ASPECT_COLOR_BIT as u32 != 0 {
com::AttachmentClear::Color { com::AttachmentClear::Color {
index: at.colorAttachment as _, index: at.colorAttachment as _,
@ -4773,7 +4773,7 @@ pub extern "C" fn gfxAcquireNextImageKHR(
None => return VkResult::VK_ERROR_OUT_OF_DATE_KHR, 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()) } { match unsafe { raw.acquire_image(timeout, semaphore.as_ref(), fence.as_ref()) } {
Ok(frame) => { Ok(frame) => {

View file

@ -5,9 +5,9 @@
#![cfg_attr(feature = "nightly", feature(core_intrinsics))] #![cfg_attr(feature = "nightly", feature(core_intrinsics))]
#[cfg(feature = "gfx-backend-dx11")] #[cfg(feature = "gfx-backend-dx11")]
extern crate gfx_backend_dx11 as back; use gfx_backend_dx11 as back;
#[cfg(feature = "gfx-backend-dx12")] #[cfg(feature = "gfx-backend-dx12")]
extern crate gfx_backend_dx12 as back; use gfx_backend_dx12 as back;
#[cfg(not(any( #[cfg(not(any(
feature = "gfx-backend-dx12", feature = "gfx-backend-dx12",
feature = "gfx-backend-dx11", feature = "gfx-backend-dx11",
@ -15,27 +15,17 @@ extern crate gfx_backend_dx12 as back;
feature = "gfx-backend-vulkan", feature = "gfx-backend-vulkan",
feature = "gfx-backend-gl", feature = "gfx-backend-gl",
)))] )))]
extern crate gfx_backend_empty as back; use gfx_backend_empty as back;
#[cfg(feature = "gfx-backend-gl")] #[cfg(feature = "gfx-backend-gl")]
extern crate gfx_backend_gl as back; use gfx_backend_gl as back;
#[cfg(feature = "gfx-backend-metal")] #[cfg(feature = "gfx-backend-metal")]
extern crate gfx_backend_metal as back; use gfx_backend_metal as back;
#[cfg(feature = "gfx-backend-vulkan")] #[cfg(feature = "gfx-backend-vulkan")]
extern crate gfx_backend_vulkan as back; use gfx_backend_vulkan as back;
extern crate gfx_hal as hal; use gfx_hal as hal;
extern crate smallvec;
extern crate copyless; use lazy_static::lazy_static;
#[macro_use] use log::{error, warn};
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;
mod conv; mod conv;
mod handle; mod handle;
@ -43,13 +33,13 @@ mod impls;
use smallvec::SmallVec; use smallvec::SmallVec;
use back::Backend as B; use crate::back::Backend as B;
use handle::{DispatchHandle, Handle}; use crate::handle::{DispatchHandle, Handle};
use std::collections::HashMap; use std::collections::HashMap;
use std::slice; use std::slice;
pub use impls::*; pub use crate::impls::*;
// Vulkan objects // Vulkan objects
pub type VkInstance = Handle<RawInstance>; pub type VkInstance = Handle<RawInstance>;

View file

@ -2,6 +2,7 @@
name = "portability-icd" name = "portability-icd"
publish = false publish = false
version = "0.1.0" version = "0.1.0"
edition = "2018"
authors = [ authors = [
"Dzmitry Malyshau <kvark@mozilla.com>", "Dzmitry Malyshau <kvark@mozilla.com>",
"Markus Siglreithmaier <m.siglreith@gmail.com>", "Markus Siglreithmaier <m.siglreith@gmail.com>",

View file

@ -1,7 +1,5 @@
#![allow(non_snake_case)] #![allow(non_snake_case)]
extern crate portability_gfx;
use portability_gfx::*; use portability_gfx::*;
use std::ffi::CStr; use std::ffi::CStr;

View file

@ -2,6 +2,7 @@
name = "portability" name = "portability"
publish = false publish = false
version = "0.1.0" version = "0.1.0"
edition = "2018"
authors = [ authors = [
"Dzmitry Malyshau <kvark@mozilla.com>", "Dzmitry Malyshau <kvark@mozilla.com>",
"Markus Siglreithmaier <m.siglreith@gmail.com>", "Markus Siglreithmaier <m.siglreith@gmail.com>",

View file

@ -1,7 +1,5 @@
#![allow(non_snake_case)] #![allow(non_snake_case)]
extern crate portability_gfx;
use portability_gfx::*; use portability_gfx::*;
// These are only shims, reexporting the gfx functions with an vk prefix. // These are only shims, reexporting the gfx functions with an vk prefix.