vulkan: use last rendered frame as background for ui
This commit is contained in:
parent
cf7aa4f310
commit
6865d74a85
|
@ -39,6 +39,7 @@ static inline void ImGui_impl_RenderDrawData(ImDrawData *draw_data, bool save_ba
|
|||
{
|
||||
context->NewFrame();
|
||||
context->BeginRenderPass();
|
||||
context->PresentLastFrame();
|
||||
}
|
||||
// Record Imgui Draw Data and draw funcs into command buffer
|
||||
ImGui_ImplVulkan_RenderDrawData(draw_data, (VkCommandBuffer)context->GetCurrentCommandBuffer());
|
||||
|
|
|
@ -692,13 +692,8 @@ void VulkanContext::Present()
|
|||
}
|
||||
}
|
||||
|
||||
extern Renderer *renderer;
|
||||
|
||||
void VulkanContext::PresentFrame(vk::ImageView imageView, vk::Offset2D extent)
|
||||
void VulkanContext::DrawFrame(vk::ImageView imageView, vk::Offset2D extent)
|
||||
{
|
||||
NewFrame();
|
||||
BeginRenderPass();
|
||||
|
||||
float marginWidth = ((float)extent.y / extent.x * width / height - 1.f) / 2.f;
|
||||
QuadVertex vtx[] = {
|
||||
{ { -1, -1, 0 }, { 0 - marginWidth, 0 } },
|
||||
|
@ -723,12 +718,32 @@ void VulkanContext::PresentFrame(vk::ImageView imageView, vk::Offset2D extent)
|
|||
commandBuffer.setScissor(0, vk::Rect2D(vk::Offset2D(0, 0), vk::Extent2D(width, height)));
|
||||
quadBuffer->Bind(commandBuffer);
|
||||
quadBuffer->Draw(commandBuffer);
|
||||
}
|
||||
|
||||
extern Renderer *renderer;
|
||||
|
||||
void VulkanContext::PresentFrame(vk::ImageView imageView, vk::Offset2D extent)
|
||||
{
|
||||
NewFrame();
|
||||
BeginRenderPass();
|
||||
|
||||
DrawFrame(imageView, extent);
|
||||
renderer->DrawOSD(false);
|
||||
EndFrame();
|
||||
|
||||
lastFrameView = imageView;
|
||||
lastFrameExtent = extent;
|
||||
}
|
||||
|
||||
void VulkanContext::PresentLastFrame()
|
||||
{
|
||||
if (lastFrameView)
|
||||
DrawFrame(lastFrameView, lastFrameExtent);
|
||||
}
|
||||
|
||||
void VulkanContext::Term()
|
||||
{
|
||||
lastFrameView = nullptr;
|
||||
ImGui_ImplVulkan_Shutdown();
|
||||
gui_term();
|
||||
if (device && pipelineCache)
|
||||
|
|
|
@ -47,6 +47,7 @@ public:
|
|||
void EndFrame();
|
||||
void Present();
|
||||
void PresentFrame(vk::ImageView imageView, vk::Offset2D extent);
|
||||
void PresentLastFrame();
|
||||
|
||||
vk::PhysicalDevice GetPhysicalDevice() const { return physicalDevice; }
|
||||
vk::Device GetDevice() const { return *device; }
|
||||
|
@ -91,6 +92,7 @@ private:
|
|||
vk::Format FindDepthFormat();
|
||||
void InitImgui();
|
||||
void DoSwapAutomation();
|
||||
void DrawFrame(vk::ImageView imageView, vk::Offset2D extent);
|
||||
vk::SurfaceKHR GetSurface() {
|
||||
#ifdef USE_SDL
|
||||
return surface;
|
||||
|
@ -181,6 +183,9 @@ private:
|
|||
std::unique_ptr<QuadPipeline> quadPipeline;
|
||||
std::unique_ptr<ShaderManager> shaderManager;
|
||||
|
||||
vk::ImageView lastFrameView;
|
||||
vk::Offset2D lastFrameExtent;
|
||||
|
||||
#ifdef VK_DEBUG
|
||||
#ifndef __ANDROID__
|
||||
vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger;
|
||||
|
|
Loading…
Reference in New Issue