webai-community / aquarium

BSD 3-Clause "New" or "Revised" License
26 stars 7 forks source link

Update all fish data in one big buffer #24

Closed JiangYizhou closed 5 years ago

JiangYizhou commented 5 years ago

Merge the fish uniform buffers to a big buffer, and update the fish data once per frame. This patch advantages in reduces buffer update per frame. Each type of fishes, in another word, each fish model instance uses offset to access to the big buffer.

In the next step, we will implement fish come and go senario and consider fish buffer allocation in the render loop. We also replace setsubdata by map buffer async.

JiangYizhou commented 5 years ago

@bbernhar @Jiawei-Shao @shaoboyan , this patch implements update fish buffer by buffer mapping async. But the performance declined a lot if applying the second patch ' Update fish buffer by buffer mapping async'. I have a quick performance tuning and it seems that mDevice.Tick() (ContextDawn::WaitABit) cost much time. I update all fish data in one staging buffer and then copy to the dest buffer in the map write call back function and also memcpy the data in the call back function. Please take a look and see if something is wrong with my logic. Thanks!

JiangYizhou commented 5 years ago

This update add buffer mapping async mode to toggle. Pass "--buffer-mapping-async" to test the functionality.