Closed laiyierjiangsu closed 8 months ago
//renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColorMake(clear_color.x clear_color.w, clear_color.y clear_color.w, clear_color.z * clear_color.w, clear_color.w)
Why is this commented?
It seems like maybe you are not properly clearing your framebuffer so previous frame or garbage data may be visible.
//renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColorMake(clear_color.x clear_color.w, clear_color.y clear_color.w, clear_color.z * clear_color.w, clear_color.w)
Why is this commented?
It seems like maybe you are not properly clearing your framebuffer so previous frame or garbage data may be visible.
Thanks ocornut.
The purpose of this line of code is to clear the render target. If enabled, it can solve the issue of extra rendering areas appearing outside the window, but this was not my original design. In this process, a third party first calls RenderOneFrame to render the image, and then I recreate a command buffer to render ImGui on the original texture. You can consider the black background in my screenshot as the game content, which I cannot capture due to sensitivity concerns.
I am wondering if it's possible to use some graphical debugging tools to find out exactly what is drawing the extra content on each edge?
https://github.com/ocornut/imgui/assets/5535552/6c3686fc-b05a-4719-9f21-13ebf4fd1421
I've uploaded a video that, despite being a bit blurry, shows the basic rendering commands. Between command 18 and command 19, the entire UI is drawn, introducing additional borders, so we can at least be sure it's not due to a lack of cleaning. I feel it's related to the overall window drawing size, but the ImGui API is very concise, and I didn't see a place to set this. Graphics APIs are new to me, so I hope a friend can give me some guidance?
You can browse the code and see exactly what ImGui_ImplMetal_RenderDrawData()
, but I am afraid this is a Metal question rather than a Dear ImGui question. Perhaps you need to set that clear color to 0,0,0,0, or find a way to disable the clearing in that render pass.
I am sympathetic to your issue but those things are common when doing graphics programming, and we don't have resources to help those cases as it is draining resources away from focusing on Dear ImGui, so I need to close this.
It'd be best if you ask on graphics or Metal forums. When you find your issue feel free to post here again as it may help future users searching for clues, if they have a similar issue.
Sure, if I have any further discoveries, I'll let you know.
Version/Branch of Dear ImGui:
Branch:master , the latest verison
Back-ends:
imgui_impl_metal.cpp
Compiler, OS:
macos + clang12
Full config/build information:
No response
Details:
I have a third-party library. After it finishes rendering, I continue to draw ImGui on the rendered result with the following code. However, a strange phenomenon occurred: there are some extra elements along the edges of the window. I'm not very familiar with graphic APIs.
I'm looking for some information:
What configurations might cause this border issue? It's possible that there is an error in my API settings. Are there any tools I can use to debug this issue?
Screenshots/Video:
Minimal, Complete and Verifiable Example code:
//imp for rendering imgui
{ ImGuiIO& io = ImGui::GetIO();
io.DisplaySize.x = view.bounds.size.width; io.DisplaySize.y = view.bounds.size.height;
if TARGET_OS_OSX
else
endif
// id commandBuffer = [self.commandQueue commandBuffer];
// MTLRenderPassDescriptor* renderPassDescriptor = view.currentRenderPassDescriptor; if (renderPassDescriptor == nil) { [commandBuffer commit]; return; }
if TARGET_OS_OSX
endif
//renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColorMake(clear_color.x clear_color.w, clear_color.y clear_color.w, clear_color.z * clear_color.w, clear_color.w); id renderEncoder = [commandBuffer renderCommandEncoderWithDescriptor:renderPassDescriptor];
[renderEncoder pushDebugGroup:@"Dear ImGui rendering"];
ImGui_ImplMetal_RenderDrawData(draw_data, commandBuffer, renderEncoder);
[renderEncoder popDebugGroup];
[renderEncoder endEncoding];
}