harrand / Topaz

C++20 Game Engine
https://harrand.github.io/Topaz/
MIT License
35 stars 3 forks source link

Bug Report: Same-frame renderer dependencies #78

Closed harrand closed 1 year ago

harrand commented 1 year ago

Describe the bug Right now, there is no concept of a renderer dependency. In my mind, and documentation's mind, two renderers running in a single frame have no guarantees at all about which one runs first/order etc.

That is actually not the case. https://github.com/harrand/Topaz/blob/71fe2485b8af632e9fe2741992e37da32c05cb5e/src/tz/gl/impl/vulkan/renderer.cpp#L1102 This will CPU block for any previously-submitted work that happened this frame. That means for two composite renderers A and B. if A runs first, B will block the thread until A finishes.

Without dependency semantics this is sensible -- if we can't specify a dependency then the only way to be safe is if all composite renderers are dependent on the previous having ran to completion. However, this is dreadful for perf if the renderers are doing unrelated work and do not need to run one-after-the-other serially.

This work is blocked by Feature Request: Renderer Dependencies #74 as to make the change beforehand now means there is no safety in the case of composite renderers in a single frame (i.e all debugui will break, for starters)

Reproduction

Expected behavior If renderer A is invoked before unrelated renderer B, B should not wait on A to finish - unless B has specified a renderer dependency on A; something only possible using the feature provided by Feature Request: Renderer Dependencies #74

Screenshots If applicable, add screenshots to help explain your problem.

Conditions (please complete the following information):

Additional context N/A

harrand commented 1 year ago

As of Topaz 4.0, you are expected to populate the render graph and timeline, telling the underlying renderer the necessary information about how your renderers should be scheduled.

As a result of doing this, there is no longer this weird implicit wait dependency on any and all composite renderers, unless explicitly specified.