skulpin
skulpin copied to clipboard
Support Metal on macOS
These changes allow skulpin to run on macOS systems without relying on MoltenVK. The skia_support
module in skulpin-renderer
has been split to create Vulkan- and Metal-specific versions of the SkiaContext
and SkiaSurface
structs. Context-creation is quite different between the two backends, but Surface-creation has a lot of overlap and could potentially share more of the implementation. The repetition that currently exists is in the interest of being able to keep the metal and vulkan crate dependencies separated.
The Renderer
itself only required minimal changes to the creation of its RafxApi
struct and an additional switch between the two versions of the cooked shaders (which now live in shaders/out/vk
and shaders/out/mtl
).
Unrelated changes involve adding support for version 0.26 of winit
and updating skia-safe
to 0.52.
Current Status
The examples run successfully without UI interaction. However, I've been able to trigger a segmentation violation by rapidly resizing the window. After a second or two of resizing the window, it crashes reliably (seemingly during the reallocation of the swapchain frame buffers?). The logging leading up to the crash looks like:
[2022-07-24T23:20:39Z INFO rafx_api::extra::swapchain_helper] Rebuild Swapchain
[2022-07-24T23:20:39Z DEBUG rafx_api::extra::swapchain_helper] Force swapchain rebuild due to changed window size
[2022-07-24T23:20:39Z INFO rafx_api::extra::swapchain_helper] Rebuild Swapchain
[2022-07-24T23:20:39Z DEBUG rafx_api::extra::swapchain_helper] Force swapchain rebuild due to changed window size
[2022-07-24T23:20:39Z INFO rafx_api::extra::swapchain_helper] Rebuild Swapchain
[2022-07-24T23:20:39Z DEBUG rafx_api::extra::swapchain_helper] Force swapchain rebuild due to changed window size
[2022-07-24T23:20:39Z INFO rafx_api::extra::swapchain_helper] Rebuild Swapchain
[2022-07-24T23:20:39Z DEBUG rafx_api::extra::swapchain_helper] Force swapchain rebuild due to changed window size
[2022-07-24T23:20:39Z INFO rafx_api::extra::swapchain_helper] Rebuild Swapchain
fish: Job 1, 'cargo run --example hello_skulp…' terminated by signal SIGSEGV (Address boundary error)
And here's the backtrace, which points to a crash here. Changing the surface creation parameters to use skia_safe::Budgeted::No
increases the number of resizings before the crash but doesn't seem to prevent it altogether, so leaving it set to Yes
may make it easier to track down the root cause.
On the other hand, it's gratifying to have gotten this far at least: