Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metal backend: secondary viewports are not rendered #6015

Closed
dmirty-kuzmenko opened this issue Dec 21, 2022 · 1 comment
Closed

Metal backend: secondary viewports are not rendered #6015

dmirty-kuzmenko opened this issue Dec 21, 2022 · 1 comment

Comments

@dmirty-kuzmenko
Copy link

Version: 18916
Branch: docking
Backend: imgui_impl_metal.mm + (imgui_impl_sdlrenderer.cpp or imgui_impl_glfw.cpp or imgui_impl_osx.mm)
Operating System: macOS 12.5 (monterey)

My Issue/Question:

The following happens even with example code provided by this repo.
On the docking branch with metal backend "child" windows are not rendered if they are outside of the main window (or some part of them is outside, for example a popup or something). Depending on the implementation (sdl vs glfw vs osx) they either completely greyed out or not shown at all. In terminal I get [CAMetalLayer nextDrawable] returning nil because device is nil. every frame.

Replacing line id<MTLDevice> device = [bd->SharedMetalContext.depthStencilState device]; in the imgui_impl_metal.mm file with id<MTLDevice> device = bd->SharedMetalContext.device; fixes the issue (shown on the video), but I did not investigate this "fix" seriously.

Screenshots/Video
imgui

@ocornut ocornut changed the title On the docking branch with metal backend windows aren't rendered if any part of them is outside of the "main" application window. Metal backend: secondary viewports are not rendered Dec 25, 2022
@ocornut
Copy link
Owner

ocornut commented Jan 3, 2023

Applied your fix, it makes sense to use device directly.

I consider this fixed, but but simultaneously I'm not sure I understand why this didn't happen before.?
ImGui_ImplMetal_NewFrame() does:

if (bd->SharedMetalContext.depthStencilState == nil)
    ImGui_ImplMetal_CreateDeviceObjects(bd->SharedMetalContext.device);

and

bool ImGui_ImplMetal_CreateDeviceObjects(id<MTLDevice> device)
{
    ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_GetBackendData();
    MTLDepthStencilDescriptor* depthStencilDescriptor = [[MTLDepthStencilDescriptor alloc] init];
    depthStencilDescriptor.depthWriteEnabled = NO;
    depthStencilDescriptor.depthCompareFunction = MTLCompareFunctionAlways;
    bd->SharedMetalContext.depthStencilState = [device newDepthStencilStateWithDescriptor:depthStencilDescriptor];
    ImGui_ImplMetal_CreateDeviceObjectsForPlatformWindows();
    ImGui_ImplMetal_CreateFontsTexture(device);

    return true;
}

I would assume depthStencilState.device would be set there?

Previous code added by @stuartcarnie, commit 6868d11 (#4821, #2778)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants