Metal backend, part 6

This commit is contained in:
tildearrow 2024-04-14 18:46:34 -05:00
parent d731a15e6d
commit 1e147ec4e5
3 changed files with 10 additions and 10 deletions

View file

@ -25,7 +25,7 @@
IMGUI_IMPL_API bool ImGui_ImplMetal_Init(id<MTLDevice> device); IMGUI_IMPL_API bool ImGui_ImplMetal_Init(id<MTLDevice> device);
IMGUI_IMPL_API void ImGui_ImplMetal_Shutdown(); 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, IMGUI_IMPL_API void ImGui_ImplMetal_RenderDrawData(ImDrawData* drawData,
id<MTLCommandBuffer> commandBuffer, id<MTLCommandBuffer> commandBuffer,
id<MTLRenderCommandEncoder> commandEncoder); id<MTLRenderCommandEncoder> 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 bool ImGui_ImplMetal_Init(MTL::Device* device);
IMGUI_IMPL_API void ImGui_ImplMetal_Shutdown(); 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, IMGUI_IMPL_API void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data,
MTL::CommandBuffer* commandBuffer, MTL::CommandBuffer* commandBuffer,
MTL::RenderCommandEncoder* commandEncoder); MTL::RenderCommandEncoder* commandEncoder);

View file

@ -99,9 +99,9 @@ bool ImGui_ImplMetal_Init(MTL::Device* device)
return ImGui_ImplMetal_Init((__bridge id<MTLDevice>)(device)); return ImGui_ImplMetal_Init((__bridge id<MTLDevice>)(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, void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data,
@ -160,14 +160,16 @@ void ImGui_ImplMetal_Shutdown()
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasViewports); 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(); ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_GetBackendData();
IM_ASSERT(bd->SharedMetalContext != nil && "No Metal context. Did you call ImGui_ImplMetal_Init() ?"); IM_ASSERT(bd->SharedMetalContext != nil && "No Metal context. Did you call ImGui_ImplMetal_Init() ?");
bd->SharedMetalContext.framebufferDescriptor = [[FramebufferDescriptor alloc] initWithRenderPassDescriptor:renderPassDescriptor]; bd->SharedMetalContext.framebufferDescriptor = [[FramebufferDescriptor alloc] initWithRenderPassDescriptor:renderPassDescriptor];
if (bd->SharedMetalContext.depthStencilState == nil) 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<MTLCommandBuffer> commandBuffer, static void ImGui_ImplMetal_SetupRenderState(ImDrawData* drawData, id<MTLCommandBuffer> commandBuffer,
@ -376,9 +378,7 @@ bool ImGui_ImplMetal_CreateDeviceObjects(id<MTLDevice> device)
depthStencilDescriptor.depthCompareFunction = MTLCompareFunctionAlways; depthStencilDescriptor.depthCompareFunction = MTLCompareFunctionAlways;
bd->SharedMetalContext.depthStencilState = [device newDepthStencilStateWithDescriptor:depthStencilDescriptor]; bd->SharedMetalContext.depthStencilState = [device newDepthStencilStateWithDescriptor:depthStencilDescriptor];
ImGui_ImplMetal_CreateDeviceObjectsForPlatformWindows(); ImGui_ImplMetal_CreateDeviceObjectsForPlatformWindows();
ImGui_ImplMetal_CreateFontsTexture(device); return ImGui_ImplMetal_CreateFontsTexture(device);
return true;
} }
void ImGui_ImplMetal_DestroyDeviceObjects() void ImGui_ImplMetal_DestroyDeviceObjects()

View file

@ -111,7 +111,7 @@ void FurnaceGUIRenderMetal::clear(ImVec4 color) {
bool FurnaceGUIRenderMetal::newFrame() { bool FurnaceGUIRenderMetal::newFrame() {
logI("Metal: newFrame()"); logI("Metal: newFrame()");
ImGui_ImplMetal_NewFrame(priv->renderPass); return ImGui_ImplMetal_NewFrame(priv->renderPass);
} }
void FurnaceGUIRenderMetal::createFontsTexture() { void FurnaceGUIRenderMetal::createFontsTexture() {