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

D3D12 back-end debug warning on empty scissor rectangle #3462

Closed
BeastLe9enD opened this issue Sep 8, 2020 · 7 comments
Closed

D3D12 back-end debug warning on empty scissor rectangle #3462

BeastLe9enD opened this issue Sep 8, 2020 · 7 comments

Comments

@BeastLe9enD
Copy link

BeastLe9enD commented Sep 8, 2020

Hello,
its seems that there is a bug in the D3D12 version that let imgui crash if you draw many objects.
If u want to test it yourself, just show the demo window and open all tree nodes / collapsing headers

it crashs at
ctx->DrawIndexedInstanced(pcmd->ElemCount, 1, pcmd->IdxOffset + global_idx_offset, pcmd->VtxOffset + global_vtx_offset, 0);
in RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandList* ctx)

@ocornut
Copy link
Owner

ocornut commented Sep 8, 2020

What happened then?

@BeastLe9enD
Copy link
Author

My fault was to tell the info queue to crash when warnings occured, thats why I closed the issue. Although, there is something against the spec, but it does not seem to cause graphical issues :)

D3D12 WARNING: ID3D12CommandList::DrawIndexedInstanced: Viewport: 0 is non-empty while the corresponding scissor rectangle is empty. Nothing will be written to the render target when this viewport is selected. In D3D12, scissor testing is always enabled. [ EXECUTION WARNING #695: DRAW_EMPTY_SCISSOR_RECTANGLE]
D3D12: BREAK enabled for the previous message, which was: [ WARNING EXECUTION #695: DRAW_EMPTY_SCISSOR_RECTANGLE ]

@ocornut ocornut reopened this Sep 8, 2020
@ocornut
Copy link
Owner

ocornut commented Sep 8, 2020

Well, if somehow the library outputs data that makes the current DX12 back-end emit warnings we should fix either the back-end either the library. However I've been unable to reproduce that warning.

I even tried to add

IM_ASSERT(r.right > r.left);
IM_ASSERT(r.bottom > r.top);

In the render loop in ImGui_ImplDX12_RenderDrawData() and it never triggered.

Could you clarify:

  • Which version are you using.
  • The exact repro (e.g. can you get to repro in examples/example_win32_dx12/ ?
  • How to enable the debug layer to break.

@ocornut ocornut changed the title ImGui D3D12 crash when drawing many objects D3D12 back-end debug warning on empty scissor rectangle Sep 8, 2020
@BeastLe9enD
Copy link
Author

Im using the newest docking branch,
its an own project with SDL2/D3D12 but im doing everything like in the example

To enable the debug layer:
First create a dxgi factory with debug:
IDXGIFactory7* pFactory; CreateDXGIFactory2(DXGI_CREATE_FACTORY_DEBUG, IID_PPV_ARGS(&pFactory));

Then create the debug interface:
ID3D12Debug* pDebugInterface; D3D12GetDebugInterface(IID_PPV_ARGS(&pDebugInterface)); pDebugInterface->EnableDebugLayer();

After that, query the info queue from the created d3d12 device:
ID3D12InfoQueue* pInfoQueue; m_pDevice->QueryInterface(IID_PPV_ARGS(&pInfoQueue)); pInfoQueue->SetBreakOnSeverity(D3D12_MESSAGE_SEVERITY_ERROR, true); pInfoQueue->SetBreakOnSeverity(D3D12_MESSAGE_SEVERITY_CORRUPTION, true); pInfoQueue->SetBreakOnSeverity(D3D12_MESSAGE_SEVERITY_WARNING, true);

There also seems to be a little bug with the multi-viewports, because the DXGI format of the pipeline state does not match with the format of the created multi-viewport window.

I fixed it with replacing the sd1.Format = DXGI_FORMAT_R8G8B8A8_UNORM; with sd1.Format = g_RTVFormat; so that the swapchain formats match!
(in imgui_impl_dx12.cpp) in line 789 (ImGui_ImplDX12_CreateWindow method)

@Hipster00
Copy link

Ok

ocornut added a commit that referenced this issue Sep 16, 2020
…face is enabled. (#3462, #3472) + misc comments & minor fixes.
ocornut pushed a commit that referenced this issue Sep 16, 2020
…dth or 0 height. (#3472, #3462)

In the event where the scissor rect is 0 width or 0 height, don't call Draw, as it generates warnings if the D3D12 Debug Layer is enabled, and nothing would have been drawn anyway.
@ocornut
Copy link
Owner

ocornut commented Sep 16, 2020

Thank you @BeastLe9enD! This has been fixed by #3472 and I've also added the SetBreakOnSeverity call in the demo code.

@ocornut
Copy link
Owner

ocornut commented Sep 16, 2020

There also seems to be a little bug with the multi-viewports, because the DXGI format of the pipeline state does not match with the format of the created multi-viewport window. I fixed it with replacing the sd1.Format = DXGI_FORMAT_R8G8B8A8_UNORM; with sd1.Format = g_RTVFormat; so that the swapchain formats match!
(in imgui_impl_dx12.cpp) in line 789 (ImGui_ImplDX12_CreateWindow method)

Also pushed this in docking branch with
e230ec5

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

3 participants