pass PhysicalDevice by value

This commit is contained in:
Rukai 2017-07-02 13:52:18 +10:00
parent a1d8c93ded
commit eb9ccd44e8
9 changed files with 20 additions and 20 deletions

View File

@ -49,7 +49,7 @@ fn main() {
// Now initializing the device.
let (device, mut queues) = {
Device::new(&physical, physical.supported_features(), &DeviceExtensions::none(),
Device::new(physical, physical.supported_features(), &DeviceExtensions::none(),
[(queue, 0.5)].iter().cloned()).expect("failed to create device")
};

View File

@ -93,7 +93,7 @@ fn main() {
let physical = PhysicalDevice::enumerate(&instance).next().expect("no device available");
let queue = physical.queue_families().next().expect("couldn't find a queue family");
let (device, mut queues) = Device::new(&physical, physical.supported_features(), &DeviceExtensions::none(), vec![(queue, 0.5)]).expect("failed to create device");
let (device, mut queues) = Device::new(physical, physical.supported_features(), &DeviceExtensions::none(), vec![(queue, 0.5)]).expect("failed to create device");
let queue = queues.next().unwrap();
// Create an image in order to generate some additional logging:

View File

@ -48,7 +48,7 @@ fn main() {
khr_swapchain: true,
.. vulkano::device::DeviceExtensions::none()
};
let (device, mut queues) = vulkano::device::Device::new(&physical, physical.supported_features(),
let (device, mut queues) = vulkano::device::Device::new(physical, physical.supported_features(),
&device_ext, [(queue, 0.5)].iter().cloned())
.expect("failed to create device");
let queue = queues.next().unwrap();

View File

@ -49,7 +49,7 @@ fn main() {
.. vulkano::device::DeviceExtensions::none()
};
let (device, mut queues) = vulkano::device::Device::new(&physical, physical.supported_features(),
let (device, mut queues) = vulkano::device::Device::new(physical, physical.supported_features(),
&device_ext, [(queue, 0.5)].iter().cloned())
.expect("failed to create device");
let queue = queues.next().unwrap();

View File

@ -145,7 +145,7 @@ fn main() {
.. vulkano::device::DeviceExtensions::none()
};
Device::new(&physical, physical.supported_features(), &device_ext,
Device::new(physical, physical.supported_features(), &device_ext,
[(queue, 0.5)].iter().cloned()).expect("failed to create device")
};

View File

@ -38,7 +38,7 @@
//! let features = Features::none();
//! let ext = DeviceExtensions::none();
//!
//! match Device::new(&physical_device, &features, &ext, Some((queue_family, 1.0))) {
//! match Device::new(physical_device, &features, &ext, Some((queue_family, 1.0))) {
//! Ok(d) => d,
//! Err(err) => panic!("Couldn't build device: {:?}", err)
//! }
@ -163,7 +163,7 @@ impl Device {
///
// TODO: return Arc<Queue> and handle synchronization in the Queue
// TODO: should take the PhysicalDevice by value
pub fn new<'a, I, Ext>(phys: &'a PhysicalDevice, requested_features: &Features,
pub fn new<'a, I, Ext>(phys: PhysicalDevice, requested_features: &Features,
extensions: Ext, queue_families: I)
-> Result<(Arc<Device>, QueuesIter), DeviceCreationError>
where I: IntoIterator<Item = (QueueFamily<'a>, f32)>,
@ -672,7 +672,7 @@ mod tests {
let family = physical.queue_families().next().unwrap();
let queues = (0 .. family.queues_count() + 1).map(|_| (family, 1.0));
match Device::new(&physical,
match Device::new(physical,
&Features::none(),
&DeviceExtensions::none(),
queues) {
@ -697,7 +697,7 @@ mod tests {
return;
}
match Device::new(&physical,
match Device::new(physical,
&features,
&DeviceExtensions::none(),
Some((family, 1.0))) {
@ -716,7 +716,7 @@ mod tests {
let family = physical.queue_families().next().unwrap();
match Device::new(&physical,
match Device::new(physical,
&Features::none(),
&DeviceExtensions::none(),
Some((family, 1.4))) {
@ -724,7 +724,7 @@ mod tests {
_ => panic!(),
};
match Device::new(&physical,
match Device::new(physical,
&Features::none(),
&DeviceExtensions::none(),
Some((family, -0.2))) {

View File

@ -245,7 +245,7 @@ macro_rules! device_extensions {
impl $rawname {
/// See the docs of supported_by_device().
pub fn supported_by_device_raw(physical_device: &PhysicalDevice) -> Result<Self, SupportedExtensionsError> {
pub fn supported_by_device_raw(physical_device: PhysicalDevice) -> Result<Self, SupportedExtensionsError> {
let vk = physical_device.instance().pointers();
let properties: Vec<vk::ExtensionProperties> = unsafe {
@ -263,7 +263,7 @@ macro_rules! device_extensions {
}
/// Returns an `Extensions` object with extensions supported by the `PhysicalDevice`.
pub fn supported_by_device(physical_device: &PhysicalDevice) -> Self {
pub fn supported_by_device(physical_device: PhysicalDevice) -> Self {
match $rawname::supported_by_device_raw(physical_device) {
Ok(l) => l,
Err(SupportedExtensionsError::LoadingError(e)) => unreachable!(),
@ -274,7 +274,7 @@ macro_rules! device_extensions {
impl $sname {
/// See the docs of supported_by_device().
pub fn supported_by_device_raw(physical_device: &PhysicalDevice) -> Result<Self, SupportedExtensionsError> {
pub fn supported_by_device_raw(physical_device: PhysicalDevice) -> Result<Self, SupportedExtensionsError> {
let vk = physical_device.instance().pointers();
let properties: Vec<vk::ExtensionProperties> = unsafe {
@ -304,7 +304,7 @@ macro_rules! device_extensions {
}
/// Returns an `Extensions` object with extensions supported by the `PhysicalDevice`.
pub fn supported_by_device(physical_device: &PhysicalDevice) -> Self {
pub fn supported_by_device(physical_device: PhysicalDevice) -> Self {
match $sname::supported_by_device_raw(physical_device) {
Ok(l) => l,
Err(SupportedExtensionsError::LoadingError(e)) => unreachable!(),

View File

@ -58,7 +58,7 @@ pub struct DisplayPlane {
impl DisplayPlane {
/// See the docs of enumerate().
pub fn enumerate_raw(device: &PhysicalDevice) -> Result<IntoIter<DisplayPlane>, OomError> {
pub fn enumerate_raw(device: PhysicalDevice) -> Result<IntoIter<DisplayPlane>, OomError> {
let vk = device.instance().pointers();
assert!(device.instance().loaded_extensions().khr_display); // TODO: return error instead
@ -117,7 +117,7 @@ impl DisplayPlane {
///
// TODO: move iterator creation here from raw constructor?
#[inline]
pub fn enumerate(device: &PhysicalDevice) -> IntoIter<DisplayPlane> {
pub fn enumerate(device: PhysicalDevice) -> IntoIter<DisplayPlane> {
DisplayPlane::enumerate_raw(device).unwrap()
}
@ -159,7 +159,7 @@ pub struct Display {
impl Display {
/// See the docs of enumerate().
pub fn enumerate_raw(device: &PhysicalDevice) -> Result<IntoIter<Display>, OomError> {
pub fn enumerate_raw(device: PhysicalDevice) -> Result<IntoIter<Display>, OomError> {
let vk = device.instance().pointers();
assert!(device.instance().loaded_extensions().khr_display); // TODO: return error instead
@ -202,7 +202,7 @@ impl Display {
///
// TODO: move iterator creation here from raw constructor?
#[inline]
pub fn enumerate(device: &PhysicalDevice) -> IntoIter<Display> {
pub fn enumerate(device: PhysicalDevice) -> IntoIter<Display> {
Display::enumerate_raw(device).unwrap()
}

View File

@ -55,7 +55,7 @@ macro_rules! gfx_dev_and_queue {
return;
}
let (device, mut queues) = match Device::new(&physical, &features,
let (device, mut queues) = match Device::new(physical, &features,
&extensions, [(queue, 0.5)].iter().cloned())
{
Ok(r) => r,