mirror of
https://github.com/italicsjenga/portability.git
synced 2024-11-26 08:51:31 +11:00
Remove lazy-static dependency
This commit is contained in:
parent
3983115cfa
commit
ac6cbf1860
18
Cargo.lock
generated
18
Cargo.lock
generated
|
@ -241,9 +241,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "env_logger"
|
name = "env_logger"
|
||||||
version = "0.7.1"
|
version = "0.8.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36"
|
checksum = "f26ecb66b4bdca6c1409b40fb255eefc2bd4f6d135dab3c3124f80ffa2a9661e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atty",
|
"atty",
|
||||||
"humantime",
|
"humantime",
|
||||||
|
@ -500,12 +500,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "humantime"
|
name = "humantime"
|
||||||
version = "1.3.0"
|
version = "2.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f"
|
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||||
dependencies = [
|
|
||||||
"quick-error",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "inplace_it"
|
name = "inplace_it"
|
||||||
|
@ -760,7 +757,6 @@ dependencies = [
|
||||||
"gfx-backend-metal",
|
"gfx-backend-metal",
|
||||||
"gfx-backend-vulkan",
|
"gfx-backend-vulkan",
|
||||||
"gfx-hal",
|
"gfx-hal",
|
||||||
"lazy_static 1.4.0",
|
|
||||||
"log",
|
"log",
|
||||||
"raw-window-handle",
|
"raw-window-handle",
|
||||||
"renderdoc",
|
"renderdoc",
|
||||||
|
@ -789,12 +785,6 @@ dependencies = [
|
||||||
"unicode-xid",
|
"unicode-xid",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "quick-error"
|
|
||||||
version = "1.2.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.7"
|
version = "1.0.7"
|
||||||
|
|
|
@ -20,8 +20,7 @@ metal-capture = ["gfx-backend-metal/auto-capture"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
copyless = "0.1.1"
|
copyless = "0.1.1"
|
||||||
env_logger = { version = "0.7", optional = true }
|
env_logger = { version = "0.8", optional = true }
|
||||||
lazy_static = "1"
|
|
||||||
log = { version = "0.4", features = ["release_max_level_error"] }
|
log = { version = "0.4", features = ["release_max_level_error"] }
|
||||||
renderdoc = { version = "0.3", optional = true }
|
renderdoc = { version = "0.3", optional = true }
|
||||||
typed-arena = "2"
|
typed-arena = "2"
|
||||||
|
|
|
@ -136,7 +136,10 @@ pub unsafe extern "C" fn gfxCreateInstance(
|
||||||
create_info.enabledExtensionCount as _,
|
create_info.enabledExtensionCount as _,
|
||||||
) {
|
) {
|
||||||
let cstr = CStr::from_ptr(*raw);
|
let cstr = CStr::from_ptr(*raw);
|
||||||
if !INSTANCE_EXTENSION_NAMES.contains(&cstr.to_bytes_with_nul()) {
|
if !INSTANCE_EXTENSIONS
|
||||||
|
.iter()
|
||||||
|
.any(|&(ref name, _)| name == &cstr.to_bytes_with_nul())
|
||||||
|
{
|
||||||
return VkResult::VK_ERROR_EXTENSION_NOT_PRESENT;
|
return VkResult::VK_ERROR_EXTENSION_NOT_PRESENT;
|
||||||
}
|
}
|
||||||
let owned = cstr.to_str().expect("Invalid extension name").to_owned();
|
let owned = cstr.to_str().expect("Invalid extension name").to_owned();
|
||||||
|
@ -934,7 +937,10 @@ pub unsafe extern "C" fn gfxCreateDevice(
|
||||||
dev_info.enabledExtensionCount as _,
|
dev_info.enabledExtensionCount as _,
|
||||||
) {
|
) {
|
||||||
let cstr = CStr::from_ptr(*raw);
|
let cstr = CStr::from_ptr(*raw);
|
||||||
if !DEVICE_EXTENSION_NAMES.contains(&cstr.to_bytes_with_nul()) {
|
if !DEVICE_EXTENSIONS
|
||||||
|
.iter()
|
||||||
|
.any(|&(ref name, _)| name == &cstr.to_bytes_with_nul())
|
||||||
|
{
|
||||||
return VkResult::VK_ERROR_EXTENSION_NOT_PRESENT;
|
return VkResult::VK_ERROR_EXTENSION_NOT_PRESENT;
|
||||||
}
|
}
|
||||||
let owned = cstr.to_str().expect("Invalid extension name").to_owned();
|
let owned = cstr.to_str().expect("Invalid extension name").to_owned();
|
||||||
|
@ -985,116 +991,61 @@ pub unsafe extern "C" fn gfxDestroyDevice(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
const INSTANCE_EXTENSIONS: &[(&'static [u8], u32)] = &[
|
||||||
// TODO: Request from backend
|
(VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_SURFACE_SPEC_VERSION),
|
||||||
static ref INSTANCE_EXTENSION_NAMES: Vec<&'static [u8]> = {
|
#[cfg(target_os = "linux")]
|
||||||
vec![
|
(
|
||||||
VK_KHR_SURFACE_EXTENSION_NAME,
|
VK_KHR_XLIB_SURFACE_EXTENSION_NAME,
|
||||||
#[cfg(target_os="linux")]
|
VK_KHR_XLIB_SURFACE_SPEC_VERSION,
|
||||||
VK_KHR_XLIB_SURFACE_EXTENSION_NAME,
|
),
|
||||||
#[cfg(target_os="linux")]
|
#[cfg(target_os = "linux")]
|
||||||
VK_KHR_XCB_SURFACE_EXTENSION_NAME,
|
(
|
||||||
#[cfg(target_os="windows")]
|
VK_KHR_XCB_SURFACE_EXTENSION_NAME,
|
||||||
VK_KHR_WIN32_SURFACE_EXTENSION_NAME,
|
VK_KHR_XCB_SURFACE_SPEC_VERSION,
|
||||||
#[cfg(feature="gfx-backend-metal")]
|
),
|
||||||
VK_EXT_METAL_SURFACE_EXTENSION_NAME,
|
#[cfg(target_os = "windows")]
|
||||||
#[cfg(target_os="macos")]
|
(
|
||||||
VK_MVK_MACOS_SURFACE_EXTENSION_NAME,
|
VK_KHR_WIN32_SURFACE_EXTENSION_NAME,
|
||||||
VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME,
|
VK_KHR_WIN32_SURFACE_SPEC_VERSION,
|
||||||
VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME,
|
),
|
||||||
]
|
#[cfg(feature = "gfx-backend-metal")]
|
||||||
};
|
(
|
||||||
|
VK_EXT_METAL_SURFACE_EXTENSION_NAME,
|
||||||
|
VK_EXT_METAL_SURFACE_SPEC_VERSION,
|
||||||
|
),
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
(
|
||||||
|
VK_MVK_MACOS_SURFACE_EXTENSION_NAME,
|
||||||
|
VK_MVK_MACOS_SURFACE_SPEC_VERSION,
|
||||||
|
),
|
||||||
|
(
|
||||||
|
VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME,
|
||||||
|
VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_SPEC_VERSION,
|
||||||
|
),
|
||||||
|
(
|
||||||
|
VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME,
|
||||||
|
VK_KHR_GET_SURFACE_CAPABILITIES_2_SPEC_VERSION,
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
static ref INSTANCE_EXTENSIONS: Vec<VkExtensionProperties> = {
|
const DEVICE_EXTENSIONS: &[(&'static [u8], u32)] = &[
|
||||||
let mut extensions = vec![
|
(
|
||||||
VkExtensionProperties {
|
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
|
||||||
extensionName: [0; 256], // VK_KHR_SURFACE_EXTENSION_NAME
|
VK_KHR_SWAPCHAIN_SPEC_VERSION,
|
||||||
specVersion: VK_KHR_SURFACE_SPEC_VERSION,
|
),
|
||||||
},
|
(
|
||||||
#[cfg(target_os="linux")]
|
VK_KHR_MAINTENANCE1_EXTENSION_NAME,
|
||||||
VkExtensionProperties {
|
VK_KHR_MAINTENANCE1_SPEC_VERSION,
|
||||||
extensionName: [0; 256], // VK_KHR_XLIB_SURFACE_EXTENSION_NAME
|
),
|
||||||
specVersion: VK_KHR_XLIB_SURFACE_SPEC_VERSION,
|
(
|
||||||
},
|
VK_EXT_DEBUG_MARKER_EXTENSION_NAME,
|
||||||
#[cfg(target_os="linux")]
|
VK_EXT_DEBUG_MARKER_SPEC_VERSION,
|
||||||
VkExtensionProperties {
|
),
|
||||||
extensionName: [0; 256], // VK_KHR_XCB_SURFACE_EXTENSION_NAME
|
(
|
||||||
specVersion: VK_KHR_XCB_SURFACE_SPEC_VERSION,
|
VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME,
|
||||||
},
|
VK_KHR_PORTABILITY_SUBSET_SPEC_VERSION,
|
||||||
#[cfg(target_os="windows")]
|
),
|
||||||
VkExtensionProperties {
|
];
|
||||||
extensionName: [0; 256], // VK_KHR_WIN32_SURFACE_EXTENSION_NAME
|
|
||||||
specVersion: VK_KHR_WIN32_SURFACE_SPEC_VERSION,
|
|
||||||
},
|
|
||||||
#[cfg(feature="gfx-backend-metal")]
|
|
||||||
VkExtensionProperties {
|
|
||||||
extensionName: [0; 256], // VK_EXT_METAL_SURFACE_EXTENSION_NAME
|
|
||||||
specVersion: VK_EXT_METAL_SURFACE_SPEC_VERSION,
|
|
||||||
},
|
|
||||||
#[cfg(target_os="macos")]
|
|
||||||
VkExtensionProperties {
|
|
||||||
extensionName: [0; 256], // VK_MVK_MACOS_SURFACE_EXTENSION_NAME
|
|
||||||
specVersion: VK_MVK_MACOS_SURFACE_SPEC_VERSION,
|
|
||||||
},
|
|
||||||
VkExtensionProperties {
|
|
||||||
extensionName: [0; 256], // VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME
|
|
||||||
specVersion: VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_SPEC_VERSION,
|
|
||||||
},
|
|
||||||
VkExtensionProperties {
|
|
||||||
extensionName: [0; 256], // VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME
|
|
||||||
specVersion: VK_KHR_GET_SURFACE_CAPABILITIES_2_SPEC_VERSION,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
for (&name, extension) in INSTANCE_EXTENSION_NAMES.iter().zip(&mut extensions) {
|
|
||||||
extension
|
|
||||||
.extensionName[.. name.len()]
|
|
||||||
.copy_from_slice(unsafe {
|
|
||||||
mem::transmute(name)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
extensions
|
|
||||||
};
|
|
||||||
|
|
||||||
static ref DEVICE_EXTENSION_NAMES: Vec<&'static [u8]> = {
|
|
||||||
vec![
|
|
||||||
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
|
|
||||||
VK_KHR_MAINTENANCE1_EXTENSION_NAME,
|
|
||||||
VK_EXT_DEBUG_MARKER_EXTENSION_NAME,
|
|
||||||
VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME,
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
static ref DEVICE_EXTENSIONS: Vec<VkExtensionProperties> = {
|
|
||||||
let mut extensions = [
|
|
||||||
VkExtensionProperties {
|
|
||||||
extensionName: [0; 256], // VK_KHR_SWAPCHAIN_EXTENSION_NAME
|
|
||||||
specVersion: VK_KHR_SWAPCHAIN_SPEC_VERSION,
|
|
||||||
},
|
|
||||||
VkExtensionProperties {
|
|
||||||
extensionName: [0; 256], // VK_KHR_MAINTENANCE1_EXTENSION_NAME
|
|
||||||
specVersion: VK_KHR_MAINTENANCE1_SPEC_VERSION,
|
|
||||||
},
|
|
||||||
VkExtensionProperties {
|
|
||||||
extensionName: [0; 256], // VK_EXT_DEBUG_MARKER_EXTENSION_NAME
|
|
||||||
specVersion: VK_EXT_DEBUG_MARKER_SPEC_VERSION,
|
|
||||||
},
|
|
||||||
VkExtensionProperties {
|
|
||||||
extensionName: [0; 256], // VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME
|
|
||||||
specVersion: VK_KHR_PORTABILITY_SUBSET_SPEC_VERSION,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
for (&name, extension) in DEVICE_EXTENSION_NAMES.iter().zip(&mut extensions) {
|
|
||||||
extension
|
|
||||||
.extensionName[.. name.len()]
|
|
||||||
.copy_from_slice(unsafe { mem::transmute(name) });
|
|
||||||
}
|
|
||||||
|
|
||||||
extensions.to_vec()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe extern "C" fn gfxEnumerateInstanceExtensionProperties(
|
pub unsafe extern "C" fn gfxEnumerateInstanceExtensionProperties(
|
||||||
|
@ -1112,10 +1063,14 @@ pub unsafe extern "C" fn gfxEnumerateInstanceExtensionProperties(
|
||||||
*property_count = num_extensions;
|
*property_count = num_extensions;
|
||||||
}
|
}
|
||||||
let properties = slice::from_raw_parts_mut(pProperties, *property_count as usize);
|
let properties = slice::from_raw_parts_mut(pProperties, *property_count as usize);
|
||||||
for i in 0..*property_count as usize {
|
for (property, &(name, specVersion)) in properties.iter_mut().zip(INSTANCE_EXTENSIONS) {
|
||||||
properties[i] = INSTANCE_EXTENSIONS[i];
|
let mut extensionName = [0i8; 256];
|
||||||
|
extensionName[..name.len()].copy_from_slice(mem::transmute(name));
|
||||||
|
*property = VkExtensionProperties {
|
||||||
|
extensionName,
|
||||||
|
specVersion,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if *property_count < num_extensions {
|
if *property_count < num_extensions {
|
||||||
return VkResult::VK_INCOMPLETE;
|
return VkResult::VK_INCOMPLETE;
|
||||||
}
|
}
|
||||||
|
@ -1141,8 +1096,13 @@ pub unsafe extern "C" fn gfxEnumerateDeviceExtensionProperties(
|
||||||
*property_count = num_extensions;
|
*property_count = num_extensions;
|
||||||
}
|
}
|
||||||
let properties = slice::from_raw_parts_mut(pProperties, *property_count as usize);
|
let properties = slice::from_raw_parts_mut(pProperties, *property_count as usize);
|
||||||
for i in 0..*property_count as usize {
|
for (property, &(name, specVersion)) in properties.iter_mut().zip(DEVICE_EXTENSIONS) {
|
||||||
properties[i] = DEVICE_EXTENSIONS[i];
|
let mut extensionName = [0i8; 256];
|
||||||
|
extensionName[..name.len()].copy_from_slice(mem::transmute(name));
|
||||||
|
*property = VkExtensionProperties {
|
||||||
|
extensionName,
|
||||||
|
specVersion,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if *property_count < num_extensions {
|
if *property_count < num_extensions {
|
||||||
|
|
|
@ -32,7 +32,6 @@ use gfx_backend_metal as back;
|
||||||
#[cfg(feature = "gfx-backend-vulkan")]
|
#[cfg(feature = "gfx-backend-vulkan")]
|
||||||
use gfx_backend_vulkan as back;
|
use gfx_backend_vulkan as back;
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
|
||||||
use log::{error, warn};
|
use log::{error, warn};
|
||||||
|
|
||||||
mod conv;
|
mod conv;
|
||||||
|
|
Loading…
Reference in a new issue