Vulkan Confusion
Posted: 01 Nov 2023, 04:29
I'm having some trouble integrating with Vulkan & GLFW using the VKRenderDevice implementation provided in NoesisApp/Render. Is there some kind of documentation or example on how to do this? So far I've just kind of been stumbling and guessing as to how to use it, mostly based on what's available in VKFactory. Here's what I'm currently doing:
Initialization:
Thanks.
Initialization:
- Initialize GLFW with window
- Initialize Vulkan (Instance, Surface, Physical Device, Device, Graphics Queue/Index, Render Queue/Index, Swapchain, Renderpass, Swapchain Images/Views/Buffers, Command pool, Command Buffers, Semaphores/Fences, with 2 frames in flight. It works with an empty render pass that just clears the screen.
- Initialize Noesis (Set handler, Set license, Init, set theme providers with embedded xaml and font, loaded a default theme application resources, Create view from that xaml, set flags). After these I fill in VKFactory::InstanceInfo and VKFactory::CreateDevice. Then VKFactory::SetRenderPass(), and finally view->GetRenderer()->Init(renderDevice).
- Spawn a renderThread that continually calls DrawFrame(), then in the main loop I continually glfwPollEvents() and view->Update(glfwGetTime()).
- View->update() is being called from main thread.
- For Vulkan drawing (DrawFrame) I wait for fences, acquire next swapchain image, reset my fence, reset my command buffer, then call the following:
VkFactory::SetCommandBuffer() with command buffer that I reset, frame number that ticks up every pass, and a safeFrameNumber that is equal to frameNumber - framesInFlight.
view->GetRenderer()->UpdateRenderTree();
view->GetRenderer()->RenderOffscreen();
view->GetRenderer()->Render();
Finally, vkQueueSubmit() and vkQueuePresentKHR().
Thanks.