From 3e716b08ad0832565a375d2a037193864d679dec Mon Sep 17 00:00:00 2001 From: Joshua Groves Date: Fri, 15 Jun 2018 18:45:05 -0600 Subject: [PATCH] Map present modes --- Cargo.lock | 31 +++++++++++++++++++++---------- libportability-gfx/src/conv.rs | 6 ++++++ libportability-gfx/src/impls.rs | 8 +++++++- 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d7f9bce..19d1345 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -244,6 +244,14 @@ name = "fuchsia-zircon-sys" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "gcc" version = "0.3.54" @@ -252,13 +260,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "gfx-backend-dx12" version = "0.1.0" -source = "git+https://github.com/gfx-rs/gfx#63826ab79f8339436f1e1b26b0e99f72d4274b67" +source = "git+https://github.com/gfx-rs/gfx#61588a5a82a24552d45931c906ebd4150ee589b3" dependencies = [ "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "derivative 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "gfx-hal 0.1.0 (git+https://github.com/gfx-rs/gfx)", "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "spirv_cross 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "winit 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -268,7 +276,7 @@ dependencies = [ [[package]] name = "gfx-backend-metal" version = "0.1.0" -source = "git+https://github.com/gfx-rs/gfx#63826ab79f8339436f1e1b26b0e99f72d4274b67" +source = "git+https://github.com/gfx-rs/gfx#61588a5a82a24552d45931c906ebd4150ee589b3" dependencies = [ "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -277,12 +285,13 @@ dependencies = [ "core-graphics 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "derivative 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "gfx-hal 0.1.0 (git+https://github.com/gfx-rs/gfx)", "io-surface 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "metal-rs 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "objc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "spirv_cross 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "winit 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -290,7 +299,7 @@ dependencies = [ [[package]] name = "gfx-backend-vulkan" version = "0.1.0" -source = "git+https://github.com/gfx-rs/gfx#63826ab79f8339436f1e1b26b0e99f72d4274b67" +source = "git+https://github.com/gfx-rs/gfx#61588a5a82a24552d45931c906ebd4150ee589b3" dependencies = [ "ash 0.24.3 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -298,7 +307,7 @@ dependencies = [ "lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "shared_library 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "winit 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "x11 2.18.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -308,11 +317,12 @@ dependencies = [ [[package]] name = "gfx-hal" version = "0.1.0" -source = "git+https://github.com/gfx-rs/gfx#63826ab79f8339436f1e1b26b0e99f72d4274b67" +source = "git+https://github.com/gfx-rs/gfx#61588a5a82a24552d45931c906ebd4150ee589b3" dependencies = [ "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -653,7 +663,7 @@ dependencies = [ [[package]] name = "smallvec" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -966,6 +976,7 @@ dependencies = [ "checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" +"checksum fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" "checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb" "checksum gfx-backend-dx12 0.1.0 (git+https://github.com/gfx-rs/gfx)" = "" "checksum gfx-backend-metal 0.1.0 (git+https://github.com/gfx-rs/gfx)" = "" @@ -1008,7 +1019,7 @@ dependencies = [ "checksum renderdoc 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3aee9badfb4078c375d2d0479ed29c9c057b51ade78f94792ba2dcb11f343e7e" "checksum rustc-demangle 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "76d7ba1feafada44f2d38eed812bd2489a03c0f5abb975799251518b68848649" "checksum shared_library 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8254bf098ce4d8d7cc7cc6de438c5488adc5297e5b7ffef88816c0a91bd289c1" -"checksum smallvec 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03dab98ab5ded3a8b43b2c80751194608d0b2aa0f1d46cf95d1c35e192844aa7" +"checksum smallvec 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "312a7df010092e73d6bbaf141957e868d4f30efd2bfd9bb1028ad91abec58514" "checksum spirv_cross 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "387a12e5de5d5cd284d07fe7edbcac83163c0b9b4304bd3a0efb1274bcda83cf" "checksum spirv_cross 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e5c30addbd9ad947994bcd75019e06d09cccbe30d481f8ce6a16e1b406235b69" "checksum syn 0.10.8 (registry+https://github.com/rust-lang/crates.io-index)" = "58fd09df59565db3399efbba34ba8a2fec1307511ebd245d0061ff9d42691673" diff --git a/libportability-gfx/src/conv.rs b/libportability-gfx/src/conv.rs index ce3eff7..fca8d15 100644 --- a/libportability-gfx/src/conv.rs +++ b/libportability-gfx/src/conv.rs @@ -568,6 +568,12 @@ pub fn map_primitive_topology(topology: VkPrimitiveTopology, patch_size: PatchSi }) } +#[inline] +pub fn map_present_mode(present_mode: VkPresentModeKHR) -> window::PresentMode { + // Vulkan and HAL values are equal + unsafe { mem::transmute(present_mode) } +} + #[inline] pub fn map_compare_op(op: VkCompareOp) -> pso::Comparison { // Vulkan and HAL values are equal diff --git a/libportability-gfx/src/impls.rs b/libportability-gfx/src/impls.rs index 2e6939d..e23e97c 100644 --- a/libportability-gfx/src/impls.rs +++ b/libportability-gfx/src/impls.rs @@ -3602,7 +3602,12 @@ pub extern "C" fn gfxGetPhysicalDeviceSurfacePresentModesKHR( pPresentModeCount: *mut u32, pPresentModes: *mut VkPresentModeKHR, ) -> VkResult { - let modes = vec![VkPresentModeKHR::VK_PRESENT_MODE_FIFO_KHR]; //TODO + let modes = vec![ + VkPresentModeKHR::VK_PRESENT_MODE_IMMEDIATE_KHR, + VkPresentModeKHR::VK_PRESENT_MODE_MAILBOX_KHR, + VkPresentModeKHR::VK_PRESENT_MODE_FIFO_KHR, + VkPresentModeKHR::VK_PRESENT_MODE_FIFO_RELAXED_KHR + ]; //TODO let output = unsafe { slice::from_raw_parts_mut(pPresentModes, *pPresentModeCount as usize) }; if output.len() > modes.len() { @@ -3631,6 +3636,7 @@ pub extern "C" fn gfxCreateSwapchainKHR( ); // TODO let config = hal::SwapchainConfig { + present_mode: conv::map_present_mode(info.presentMode), color_format: conv::map_format(info.imageFormat).unwrap(), depth_stencil_format: None, image_count: info.minImageCount,