From 7d7a0f9e447546cfa57759326044bc37679f92c7 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Fri, 16 Feb 2018 10:31:10 -0500 Subject: [PATCH] Base on gfx-rs master revision --- libportability-gfx/Cargo.toml | 7 +++---- libportability-gfx/src/handle.rs | 8 +++++++- libportability-gfx/src/impls.rs | 9 +++------ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/libportability-gfx/Cargo.toml b/libportability-gfx/Cargo.toml index a98e8bf..64bcbf7 100644 --- a/libportability-gfx/Cargo.toml +++ b/libportability-gfx/Cargo.toml @@ -16,15 +16,14 @@ lazy_static = "1.0" [dependencies.gfx-hal] git = "https://github.com/gfx-rs/gfx" -branch = "portable" +rev = "14a0d6c0976cdbc882a6f63bced18a9b2bf13f5f" [dependencies.gfx-backend-vulkan] git = "https://github.com/gfx-rs/gfx" -branch = "portable" -features = ["portable"] +rev = "14a0d6c0976cdbc882a6f63bced18a9b2bf13f5f" optional = true [target.'cfg(windows)'.dependencies.gfx-backend-dx12] git = "https://github.com/gfx-rs/gfx" -branch = "portable" +rev = "14a0d6c0976cdbc882a6f63bced18a9b2bf13f5f" optional = true diff --git a/libportability-gfx/src/handle.rs b/libportability-gfx/src/handle.rs index b38bb79..3fc652d 100644 --- a/libportability-gfx/src/handle.rs +++ b/libportability-gfx/src/handle.rs @@ -1,5 +1,5 @@ use VK_NULL_HANDLE; -use std::{fmt, ops}; +use std::{borrow, fmt, ops}; #[repr(C)] pub struct Handle(*mut T); @@ -40,6 +40,12 @@ impl ops::DerefMut for Handle { } } +impl borrow::Borrow for Handle { + fn borrow(&self) -> &T { + unsafe { &*self.0 } + } +} + impl fmt::Debug for Handle { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { write!(formatter, "Handle({:p})", self.0) diff --git a/libportability-gfx/src/impls.rs b/libportability-gfx/src/impls.rs index ce9f5df..f69fe42 100644 --- a/libportability-gfx/src/impls.rs +++ b/libportability-gfx/src/impls.rs @@ -276,7 +276,7 @@ pub extern "C" fn gfxCreateDevice( let request_infos = queue_infos .iter() .map(|info| { - let family = adapter.queue_families[info.queueFamilyIndex as usize].clone(); + let family = &adapter.queue_families[info.queueFamilyIndex as usize]; (family, vec![1.0; info.queueCount as usize]) }) .collect::>(); @@ -417,11 +417,8 @@ pub extern "C" fn gfxQueueSubmit( assert_eq!(submitCount, 1); // TODO; let submission = unsafe { *pSubmits }; - let cmd_buffers = unsafe { + let cmd_slice = unsafe { slice::from_raw_parts(submission.pCommandBuffers, submission.commandBufferCount as _) - .into_iter() - .map(|cmd_buffer| **cmd_buffer) - .collect::>() }; let wait_semaphores = unsafe { let semaphores = slice::from_raw_parts(submission.pWaitSemaphores, submission.waitSemaphoreCount as _); @@ -440,7 +437,7 @@ pub extern "C" fn gfxQueueSubmit( }; let submission = hal::queue::RawSubmission { - cmd_buffers: &cmd_buffers, + cmd_buffers: cmd_slice.iter().cloned(), wait_semaphores: &wait_semaphores, signal_semaphores: &signal_semaphores, };