gfx-rs / gfx

[maintenance mode] A low-overhead Vulkan-like GPU API for Rust.
http://gfx-rs.github.io/
Apache License 2.0
5.35k stars 551 forks source link

Low level interop with Vulkan backend #3762

Closed zarik5 closed 3 years ago

zarik5 commented 3 years ago

Related issues: #3698 #3761 https://github.com/blaind/xrbevy/issues/1

This PR exposes some Vulkan-backend-specific details needed for interop with other low level APIs. In particular this PR aims to implement a minimum viable API to allow OpenXR integration as a separate crate.

This PR is nowhere complete. I opened it to get some feedback; this is my first PR on a project the size of gfx-hal.

This is the first of multiple PRs needed for OpenXR support in wgpu.

PR checklist:

EDIT: To make things clear, this is another take on #3761. Me and @blaind are working together on this route.

zarik5 commented 3 years ago

I see some fields of the backend structs Instance, PhysicalDevice, Device etc. are pub. Shouldn't they be pub(crate)? If some fields need to be made public (for example as part of this PR) I think getter methods should be preferred.

zarik5 commented 3 years ago

For now I remove ::raw() methods. They are not needed for the OpenXR integration and it is not clear what should be exposed for potential integration with other APIs (which might require Vulkan objects created by gfx-hal). This can be deferred to a future PR.

zarik5 commented 3 years ago

@kvark Thank you! The work here is not finished, I'm developing this API while working on a minimum example for integration with OpenXR. I have to work around the missing support of multiview in gfx-hal, which should be handled in another PR.

zarik5 commented 3 years ago

The PR is ready. I tested it with this example. I took the vulkan.rs example from openxrs and converted most of vulkan code to gfx-hal. I had some problems with crashing on close, fixed by using DropGuard on vk_instance and vk_device.

bors[bot] commented 3 years ago

Build succeeded: