From 1e147ec4e53ff05ca4a578ff0ee13a667352bf51 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 14 Apr 2024 18:46:34 -0500 Subject: [PATCH] Metal backend, part 6 --- extern/imgui_patched/backends/imgui_impl_metal.h | 4 ++-- extern/imgui_patched/backends/imgui_impl_metal.mm | 14 +++++++------- src/gui/render/renderMetal.mm | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/extern/imgui_patched/backends/imgui_impl_metal.h b/extern/imgui_patched/backends/imgui_impl_metal.h index 83b3ee8d0..d494540df 100644 --- a/extern/imgui_patched/backends/imgui_impl_metal.h +++ b/extern/imgui_patched/backends/imgui_impl_metal.h @@ -25,7 +25,7 @@ IMGUI_IMPL_API bool ImGui_ImplMetal_Init(id device); IMGUI_IMPL_API void ImGui_ImplMetal_Shutdown(); -IMGUI_IMPL_API void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor); +IMGUI_IMPL_API bool ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor); IMGUI_IMPL_API void ImGui_ImplMetal_RenderDrawData(ImDrawData* drawData, id commandBuffer, id commandEncoder); @@ -51,7 +51,7 @@ IMGUI_IMPL_API void ImGui_ImplMetal_DestroyDeviceObjects(); IMGUI_IMPL_API bool ImGui_ImplMetal_Init(MTL::Device* device); IMGUI_IMPL_API void ImGui_ImplMetal_Shutdown(); -IMGUI_IMPL_API void ImGui_ImplMetal_NewFrame(MTL::RenderPassDescriptor* renderPassDescriptor); +IMGUI_IMPL_API bool ImGui_ImplMetal_NewFrame(MTL::RenderPassDescriptor* renderPassDescriptor); IMGUI_IMPL_API void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data, MTL::CommandBuffer* commandBuffer, MTL::RenderCommandEncoder* commandEncoder); diff --git a/extern/imgui_patched/backends/imgui_impl_metal.mm b/extern/imgui_patched/backends/imgui_impl_metal.mm index b29b4f26a..930806dfa 100644 --- a/extern/imgui_patched/backends/imgui_impl_metal.mm +++ b/extern/imgui_patched/backends/imgui_impl_metal.mm @@ -99,9 +99,9 @@ bool ImGui_ImplMetal_Init(MTL::Device* device) return ImGui_ImplMetal_Init((__bridge id)(device)); } -void ImGui_ImplMetal_NewFrame(MTL::RenderPassDescriptor* renderPassDescriptor) +bool ImGui_ImplMetal_NewFrame(MTL::RenderPassDescriptor* renderPassDescriptor) { - ImGui_ImplMetal_NewFrame((__bridge MTLRenderPassDescriptor*)(renderPassDescriptor)); + return ImGui_ImplMetal_NewFrame((__bridge MTLRenderPassDescriptor*)(renderPassDescriptor)); } void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data, @@ -160,14 +160,16 @@ void ImGui_ImplMetal_Shutdown() io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasViewports); } -void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor) +bool ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor) { ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_GetBackendData(); IM_ASSERT(bd->SharedMetalContext != nil && "No Metal context. Did you call ImGui_ImplMetal_Init() ?"); bd->SharedMetalContext.framebufferDescriptor = [[FramebufferDescriptor alloc] initWithRenderPassDescriptor:renderPassDescriptor]; if (bd->SharedMetalContext.depthStencilState == nil) - ImGui_ImplMetal_CreateDeviceObjects(bd->SharedMetalContext.device); + return ImGui_ImplMetal_CreateDeviceObjects(bd->SharedMetalContext.device); + + return true; } static void ImGui_ImplMetal_SetupRenderState(ImDrawData* drawData, id commandBuffer, @@ -376,9 +378,7 @@ bool ImGui_ImplMetal_CreateDeviceObjects(id device) depthStencilDescriptor.depthCompareFunction = MTLCompareFunctionAlways; bd->SharedMetalContext.depthStencilState = [device newDepthStencilStateWithDescriptor:depthStencilDescriptor]; ImGui_ImplMetal_CreateDeviceObjectsForPlatformWindows(); - ImGui_ImplMetal_CreateFontsTexture(device); - - return true; + return ImGui_ImplMetal_CreateFontsTexture(device); } void ImGui_ImplMetal_DestroyDeviceObjects() diff --git a/src/gui/render/renderMetal.mm b/src/gui/render/renderMetal.mm index 70c9844a7..8568745eb 100644 --- a/src/gui/render/renderMetal.mm +++ b/src/gui/render/renderMetal.mm @@ -111,7 +111,7 @@ void FurnaceGUIRenderMetal::clear(ImVec4 color) { bool FurnaceGUIRenderMetal::newFrame() { logI("Metal: newFrame()"); - ImGui_ImplMetal_NewFrame(priv->renderPass); + return ImGui_ImplMetal_NewFrame(priv->renderPass); } void FurnaceGUIRenderMetal::createFontsTexture() {