Sharing 3D Vulkan Renderer and Skia

91 views
Skip to first unread message

Paul

unread,
May 25, 2022, 6:50:16 PMMay 25
to skia-discuss
  Hello,

I am new to Skia and had a few questions.  I have built the Hello World example and set it to use the Vulkan backend.  I would like to potentially work Skia into an existing 3D Vulkan renderer, where Skia would be the UI.  To do so, I believe the following would have to be done (using the Hello World as an example):
  1. Initialize the base Vulkan objects: Instance, Physical Device, Device, Graphics Queue, and Graphics Queue Index on my end.  Pass those values in the GrVkBackendContext struct.  Update/edit VulkanWindowContext::initializeContext() to take the struct where eventually GrDirectContext::MakeVulkan() gets called.  This seems to roughly follow the guidelines here: https://skia.org/docs/user/special/vulkan.  The VulkanWindowContext class initializes the swapchain/surface/layout etc.  This is the class located in tools/sk_app/VulkanWindowContext.h.
  2. On my end (not with Skia): Create pipelines, depth buffer, etc. for 3D rendering.  Draw to the shared VkImages (VkImageViews on my end using the VkImage objects created from VulkanWindowContext)
    1. Use fences/semaphores to ensure that my drawing finishes before Skia draws
  3. Skia draws on top.  Depth testing is disabled.
    1. Use fences/semaphores to ensure Skia finishes drawing
Unfortunately, I have not found too much on working Skia into an existing 3D Vulkan renderer, and I wonder if this approach is the best way to go about it.  This leads me to a few questions:
  1. Is Skia expecting all features on the Physical Device to be activated? I am concerned that passing the logical device with minimal features enabled may lead to crashes due to Skia expecting an enabled feature.
  2. Is this a normal use case for Skia?
  3. Are there any major pitfalls with this approach?
Thank you,

Paul
Reply all
Reply to author
Forward
0 new messages