mirror of
https://github.com/italicsjenga/portability.git
synced 2024-11-22 15:01:31 +11:00
commit
e90c0fdf59
28
Cargo.toml
28
Cargo.toml
|
@ -1,22 +1,6 @@
|
|||
[package]
|
||||
name = "portability"
|
||||
version = "0.1.0"
|
||||
authors = ["Dzmitry Malyshau <kvark@mozilla.com>"]
|
||||
|
||||
[lib]
|
||||
name = "portability"
|
||||
crate-type = ["staticlib"]
|
||||
|
||||
[dependencies]
|
||||
winit = "0.7"
|
||||
|
||||
[dependencies.gfx-hal]
|
||||
#path = "../gfx/src/hal"
|
||||
git = "https://github.com/kvark/gfx-rs"
|
||||
branch = "portable"
|
||||
|
||||
[dependencies.gfx-backend-vulkan]
|
||||
#path = "../gfx/src/backend/vulkan"
|
||||
git = "https://github.com/kvark/gfx-rs"
|
||||
branch = "portable"
|
||||
features = ["portable"]
|
||||
[workspace]
|
||||
members = [
|
||||
"libportability",
|
||||
"libportability-gfx",
|
||||
"libportability-icd",
|
||||
]
|
||||
|
|
4
Makefile
4
Makefile
|
@ -19,8 +19,8 @@ binding: $(BINDING)
|
|||
$(BINDING): $(VULKAN_DIR)/vulkan/*.h
|
||||
bindgen --no-layout-tests --rustfmt-bindings $(VULKAN_DIR)/vulkan/vulkan.h -o $(BINDING)
|
||||
|
||||
$(LIBRARY): src/*.rs Cargo.toml $(wildcard Cargo.lock)
|
||||
cargo build
|
||||
$(LIBRARY): libportability/src/*.rs libportability-gfx/src/*.rs Cargo.toml $(wildcard Cargo.lock)
|
||||
cargo build -p portability
|
||||
mkdir -p target/native
|
||||
|
||||
$(NATIVE_DIR)/%.o: native/%.cpp $(DEPS) Makefile
|
||||
|
|
21
libportability-gfx/Cargo.toml
Normal file
21
libportability-gfx/Cargo.toml
Normal file
|
@ -0,0 +1,21 @@
|
|||
[package]
|
||||
name = "portability-gfx"
|
||||
version = "0.1.0"
|
||||
authors = ["Dzmitry Malyshau <kvark@mozilla.com>"]
|
||||
|
||||
[lib]
|
||||
name = "portability_gfx"
|
||||
|
||||
[dependencies]
|
||||
lazy_static = "1.0"
|
||||
|
||||
[dependencies.gfx-hal]
|
||||
#path = "../gfx/src/hal"
|
||||
git = "https://github.com/kvark/gfx-rs"
|
||||
branch = "portable"
|
||||
|
||||
[dependencies.gfx-backend-vulkan]
|
||||
#path = "../gfx/src/backend/vulkan"
|
||||
git = "https://github.com/kvark/gfx-rs"
|
||||
branch = "portable"
|
||||
features = ["portable"]
|
1270
libportability-gfx/src/impls.rs
Normal file
1270
libportability-gfx/src/impls.rs
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
11
libportability-icd/Cargo.toml
Normal file
11
libportability-icd/Cargo.toml
Normal file
|
@ -0,0 +1,11 @@
|
|||
[package]
|
||||
name = "portability-icd"
|
||||
version = "0.1.0"
|
||||
authors = ["Dzmitry Malyshau <kvark@mozilla.com>"]
|
||||
|
||||
[lib]
|
||||
name = "portability_icd"
|
||||
crate-type = ["dylib"]
|
||||
|
||||
[dependencies]
|
||||
portability-gfx = { path = "../libportability-gfx" }
|
7
libportability-icd/portability_debug.json
Normal file
7
libportability-icd/portability_debug.json
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"file_format_version": "1.0.0",
|
||||
"ICD": {
|
||||
"library_path": "..\\target\\debug\\portability_icd.dll",
|
||||
"api_version": "1.0.0"
|
||||
}
|
||||
}
|
58
libportability-icd/src/lib.rs
Normal file
58
libportability-icd/src/lib.rs
Normal file
|
@ -0,0 +1,58 @@
|
|||
#![allow(non_snake_case)]
|
||||
|
||||
extern crate portability_gfx;
|
||||
|
||||
use portability_gfx::*;
|
||||
|
||||
use std::ffi::CStr;
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
|
||||
const ICD_VERSION: u32 = 5;
|
||||
|
||||
macro_rules! proc_addr {
|
||||
($name:expr, $($vk:pat => $gfx:expr),*) => (
|
||||
match $name {
|
||||
$(
|
||||
stringify!($vk) => unsafe { mem::transmute::<_, PFN_vkVoidFunction>($gfx as *const ()) }
|
||||
),*
|
||||
_ => None
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn vk_icdGetInstanceProcAddr(
|
||||
instance: VkInstance, pName: *const ::std::os::raw::c_char,
|
||||
) -> PFN_vkVoidFunction {
|
||||
let name = unsafe { CStr::from_ptr(pName) };
|
||||
let name = match name.to_str() {
|
||||
Ok(name) => name,
|
||||
Err(_) => return None,
|
||||
};
|
||||
|
||||
proc_addr!{ name,
|
||||
vkCreateInstance => gfxCreateInstance,
|
||||
vkEnumerateInstanceExtensionProperties => gfxEnumerateInstanceExtensionProperties
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn vk_icdNegotiateLoaderICDInterfaceVersion(
|
||||
pSupportedVersion: *mut ::std::os::raw::c_uint,
|
||||
) -> VkResult {
|
||||
let supported_version = unsafe { &mut *pSupportedVersion };
|
||||
if *supported_version > ICD_VERSION {
|
||||
*supported_version = ICD_VERSION;
|
||||
}
|
||||
|
||||
VkResult::VK_SUCCESS
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn vk_icdGetPhysicalDeviceProcAddr(
|
||||
instance: VkInstance, pName: *const ::std::os::raw::c_char,
|
||||
) -> PFN_vkVoidFunction {
|
||||
unimplemented!()
|
||||
}
|
||||
|
11
libportability/Cargo.toml
Normal file
11
libportability/Cargo.toml
Normal file
|
@ -0,0 +1,11 @@
|
|||
[package]
|
||||
name = "portability"
|
||||
version = "0.1.0"
|
||||
authors = ["Dzmitry Malyshau <kvark@mozilla.com>"]
|
||||
|
||||
[lib]
|
||||
name = "portability"
|
||||
crate-type = ["staticlib"]
|
||||
|
||||
[dependencies]
|
||||
portability-gfx = { path = "../libportability-gfx" }
|
208
libportability/src/lib.rs
Normal file
208
libportability/src/lib.rs
Normal file
|
@ -0,0 +1,208 @@
|
|||
#![allow(non_snake_case)]
|
||||
|
||||
extern crate portability_gfx;
|
||||
|
||||
use portability_gfx::*;
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn vkCreateInstance(
|
||||
pCreateInfo: *const VkInstanceCreateInfo,
|
||||
pAllocator: *const VkAllocationCallbacks,
|
||||
pInstance: *mut VkInstance,
|
||||
) -> VkResult {
|
||||
gfxCreateInstance(pCreateInfo, pAllocator, pInstance)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn vkDestroyInstance(
|
||||
instance: VkInstance,
|
||||
pAllocator: *const VkAllocationCallbacks,
|
||||
) {
|
||||
gfxDestroyInstance(instance, pAllocator)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn vkEnumeratePhysicalDevices(
|
||||
instance: VkInstance,
|
||||
pPhysicalDeviceCount: *mut u32,
|
||||
pPhysicalDevices: *mut VkPhysicalDevice,
|
||||
) -> VkResult {
|
||||
gfxEnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn vkGetPhysicalDeviceQueueFamilyProperties(
|
||||
adapter: VkPhysicalDevice,
|
||||
pQueueFamilyPropertyCount: *mut u32,
|
||||
pQueueFamilyProperties: *mut VkQueueFamilyProperties,
|
||||
) {
|
||||
gfxGetPhysicalDeviceQueueFamilyProperties(adapter, pQueueFamilyPropertyCount, pQueueFamilyProperties)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn vkCreateDevice(
|
||||
adapter: VkPhysicalDevice,
|
||||
pCreateInfo: *const VkDeviceCreateInfo,
|
||||
pAllocator: *const VkAllocationCallbacks,
|
||||
pDevice: *mut VkDevice,
|
||||
) -> VkResult {
|
||||
gfxCreateDevice(adapter, pCreateInfo, pAllocator, pDevice)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn vkDestroyDevice(
|
||||
device: VkDevice,
|
||||
pAllocator: *const VkAllocationCallbacks,
|
||||
) {
|
||||
gfxDestroyDevice(device, pAllocator)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn vkCreateImageView(
|
||||
device: VkDevice,
|
||||
pCreateInfo: *const VkImageViewCreateInfo,
|
||||
pAllocator: *const VkAllocationCallbacks,
|
||||
pView: *mut VkImageView,
|
||||
) -> VkResult {
|
||||
gfxCreateImageView(device, pCreateInfo, pAllocator, pView)
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern fn vkDestroyImageView(
|
||||
device: VkDevice,
|
||||
imageView: VkImageView,
|
||||
pAllocator: *const VkAllocationCallbacks,
|
||||
) {
|
||||
gfxDestroyImageView(device, imageView, pAllocator)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn vkCreateCommandPool(
|
||||
device: VkDevice,
|
||||
pCreateInfo: *const VkCommandPoolCreateInfo,
|
||||
pAllocator: *const VkAllocationCallbacks,
|
||||
pCommandPool: *mut VkCommandPool,
|
||||
) -> VkResult {
|
||||
gfxCreateCommandPool(device, pCreateInfo, pAllocator, pCommandPool)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn vkDestroyCommandPool(
|
||||
device: VkDevice,
|
||||
commandPool: VkCommandPool,
|
||||
pAllocator: *const VkAllocationCallbacks,
|
||||
) {
|
||||
gfxDestroyCommandPool(device, commandPool, pAllocator)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn vkResetCommandPool(
|
||||
device: VkDevice,
|
||||
commandPool: VkCommandPool,
|
||||
flags: VkCommandPoolResetFlags,
|
||||
) -> VkResult {
|
||||
gfxResetCommandPool(device, commandPool, flags)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn vkAllocateCommandBuffers(
|
||||
device: VkDevice,
|
||||
pAllocateInfo: *const VkCommandBufferAllocateInfo,
|
||||
pCommandBuffers: *mut VkCommandBuffer,
|
||||
) -> VkResult {
|
||||
gfxAllocateCommandBuffers(device, pAllocateInfo, pCommandBuffers)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn vkFreeCommandBuffers(
|
||||
device: VkDevice,
|
||||
commandPool: VkCommandPool,
|
||||
commandBufferCount: u32,
|
||||
pCommandBuffers: *const VkCommandBuffer,
|
||||
) {
|
||||
gfxFreeCommandBuffers(device, commandPool, commandBufferCount, pCommandBuffers)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn vkDestroySurfaceKHR(
|
||||
instance: VkInstance,
|
||||
surface: VkSurfaceKHR,
|
||||
pAllocator: *const VkAllocationCallbacks,
|
||||
) {
|
||||
gfxDestroySurfaceKHR(instance, surface, pAllocator)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn vkGetPhysicalDeviceSurfaceSupportKHR(
|
||||
adapter: VkPhysicalDevice,
|
||||
queueFamilyIndex: u32,
|
||||
surface: VkSurfaceKHR,
|
||||
pSupported: *mut VkBool32,
|
||||
) -> VkResult {
|
||||
gfxGetPhysicalDeviceSurfaceSupportKHR(adapter, queueFamilyIndex, surface, pSupported)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn vkGetPhysicalDeviceSurfaceCapabilitiesKHR(
|
||||
adapter: VkPhysicalDevice,
|
||||
surface: VkSurfaceKHR,
|
||||
pSurfaceCapabilities: *mut VkSurfaceCapabilitiesKHR,
|
||||
) -> VkResult {
|
||||
gfxGetPhysicalDeviceSurfaceCapabilitiesKHR(adapter, surface, pSurfaceCapabilities)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn vkGetPhysicalDeviceSurfaceFormatsKHR(
|
||||
adapter: VkPhysicalDevice,
|
||||
surface: VkSurfaceKHR,
|
||||
pSurfaceFormatCount: *mut u32,
|
||||
pSurfaceFormats: *mut VkSurfaceFormatKHR,
|
||||
) -> VkResult {
|
||||
gfxGetPhysicalDeviceSurfaceFormatsKHR(adapter, surface, pSurfaceFormatCount, pSurfaceFormats)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn vkGetPhysicalDeviceSurfacePresentModesKHR(
|
||||
adapter: VkPhysicalDevice,
|
||||
surface: VkSurfaceKHR,
|
||||
pPresentModeCount: *mut u32,
|
||||
pPresentModes: *mut VkPresentModeKHR,
|
||||
) -> VkResult {
|
||||
gfxGetPhysicalDeviceSurfacePresentModesKHR(adapter, surface, pPresentModeCount, pPresentModes)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn vkCreateSwapchainKHR(
|
||||
device: VkDevice,
|
||||
pCreateInfo: *const VkSwapchainCreateInfoKHR,
|
||||
pAllocator: *const VkAllocationCallbacks,
|
||||
pSwapchain: *mut VkSwapchainKHR,
|
||||
) -> VkResult {
|
||||
gfxCreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain)
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern fn vkDestroySwapchainKHR(
|
||||
device: VkDevice,
|
||||
swapchain: VkSwapchainKHR,
|
||||
pAllocator: *const VkAllocationCallbacks,
|
||||
) {
|
||||
gfxDestroySwapchainKHR(device, swapchain, pAllocator)
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern fn vkGetSwapchainImagesKHR(
|
||||
device: VkDevice,
|
||||
swapchain: VkSwapchainKHR,
|
||||
pSwapchainImageCount: *mut u32,
|
||||
pSwapchainImages: *mut VkImage,
|
||||
) -> VkResult {
|
||||
gfxGetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn vkCreateWin32SurfaceKHR(
|
||||
instance: VkInstance,
|
||||
pCreateInfos: *const VkWin32SurfaceCreateInfoKHR,
|
||||
pAllocator: *const VkAllocationCallbacks,
|
||||
pSurface: *mut VkSurfaceKHR,
|
||||
) -> VkResult {
|
||||
gfxCreateWin32SurfaceKHR(instance, pCreateInfos, pAllocator, pSurface)
|
||||
}
|
Loading…
Reference in a new issue