meta4d-me / CatDogEngine

A cross-platform game engine/editor written in modern C++ (WIP)
GNU General Public License v2.0
161 stars 16 forks source link

Fix crash when editor launches at the first time #194

Closed T-rvw closed 1 year ago

T-rvw commented 1 year ago

In current init logic:

  1. Init EC World
  2. Init Bgfx and create GPU resources and renderers
  3. Build shaders

After building all shaders, the main thread continues to update. It is OK in the single thread case. But bgfx will create another render thread to call bgfx::renderframe to flush commands.

We need to split step 2:

  1. Init EC World
  2. Init Bgfx
  3. Build shaders
  4. Create GPU resources and renderers

So we will create resources and renderers in the same frame with update logic which can keep safe for recording graphics API commands.

I named step 4 as CreateRenderGraph as we will implement RDG to replace mannual written rendering orders and dependencies.

T-rvw commented 1 year ago

Close #194