Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make PhysicalDevice an independent object #1967

Merged
merged 4 commits into from Sep 10, 2022

Conversation

Rua
Copy link
Contributor

@Rua Rua commented Sep 9, 2022

Depends on #1966.

Changelog:

- **Breaking** Changes to `PhysicalDevice`:
  - `PhysicalDevice::enumerate` has been replaced with `Instance::enumerate_physical_devices`. This function returns `Arc<PhysicalDevice>`.
  - Enumerating physical devices multiple times now retrieves the list of devices each time, instead of only at instance creation. This makes it possible to handle devices that are added/removed during runtime.
  - `PhysicalDevice` now owns instead of borrows from its parent `Instance`, so it has no more type parameter.
  - Added `extension_properties`, `memory_properties` and `queue_family_properties` method to get the full properties directly.
  - `MemoryType`, `MemoryHeap` and `QueueFamily` have been removed. Where they were used, you now provide a `u32` index into the `memory_properties().memory_types`, `memory_properties().memory_heaps` and `queue_family_properties()` arrays.
  - `QueueFamily::supports_surface` has been replaced with `PhysicalDevice::surface_support`, to match the Vulkan structure.
  - `QueueCreateInfo` now implements `Default` (with a default `queue_family_index` of 0).
  - `Queue::family` has been renamed to `queue_family_index`.

This is based on a request that was made on the Vulkano discord. It doesn't make sense to keep the physical device data in the instance permanently, because devices can be added or removed while the program is running. So now, they are retrieved fresh each time you enumerate.

The changes to MemoryType, MemoryHeap and QueueFamily are made to bring the API a bit closer to Vulkan. While these types did add a layer of type system-level safety, they were also a bit cumbersome to use, and couldn't be stored anywhere because they had a lifetime parameter. So most of the time, you'd end up storing an index anyway.

@Rua Rua changed the title Physicaldevice Make PhysicalDevice an independent object Sep 9, 2022
Copy link
Member

@AustinJ235 AustinJ235 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solved the git conflicts (Weren't actually any conflicts, just git being silly).

Great work!

@AustinJ235 AustinJ235 merged commit 4abc27b into vulkano-rs:master Sep 10, 2022
AustinJ235 added a commit that referenced this pull request Sep 10, 2022
@Rua Rua deleted the physicaldevice branch September 17, 2022 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants