aconstlink / motor

Software Framework for Audio/Visual/Interactive Real-Time Applications
MIT License
1 stars 0 forks source link

Imgui rendering bug on D3D11 backend #37

Closed aconstlink closed 5 months ago

aconstlink commented 5 months ago

Current state:

image

At the moment, I do not have any clue where this could come from.

aconstlink commented 5 months ago

If the sleep in the test application is removed, the gui renders corretly:

image

This piece of code is removed.

std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) ) ;

It seems the issue is in the synchronization of how render_engine is doing it. See the render_frame function

aconstlink commented 5 months ago

It seems the bug happens only if the geometry object is not configured properly in the d3d11 backend. If construct_geo is called with 0 sized geometry and updated subsequently, the bug happens. If the construct_geo is called with a proper != 0 geometry count, the bug does not happen. So the bug should be around there. See construct_geo in d3d11.cpp.

Here I just altered the imgui buffer so only 4 vertices and 6 indices are rendered through the imgui motor impl with just too little construct_geo calls:

image

But if the call to construct_geo is done with a geometry count != 0:

image

It seems, this is a timing bug. If the call to the function is done in the correct moment the rendering works. Otherwise not.

aconstlink commented 5 months ago

In d3d11 backend, there was no index buffer created during geometry configuration if no indices were in the buffer. So now the index buffer is created but the rendering condition for DrawIndexed needed to change with it.