libcala / cala

Cross-platform system interface for hardware IO
https://libcala.github.io/cala/
Apache License 2.0
54 stars 5 forks source link

Rendering Optimization #2

Open AldaronLau opened 6 years ago

AldaronLau commented 6 years ago

I haven't focused much on optimization yet. And, it is quite important. A simple-ish game I'm working on goes down to as low as 9FPS under Vulkan. I ran perf to find the problems. These functions seem to be taking up the most time:

This seems to be related to a few algorithms I've come up with that need to get optimized.

  1. Depth Sort - Opaque objects sorted front to back, alpha back to front. Should stop using Vector::length and rather the z value multiplied by rotation.
  2. Batch Rendering of Shapes - Needs to be optimized to not re-bind the vertex buffer when the shape does not change
  3. Matrix Transforms - Camera needs to be handled specially so not all shapes are updated one by one.

By fixing these algorithms I hope to run at least 60FPS on my laptop.

AldaronLau commented 6 years ago

Update: With only running 2D rendering here's the perf output: screenshot from 2018-09-14 20-28-43 This gets about 50 fps on my code.

3D rendering & 2D rendering perf output: screenshot from 2018-09-14 20-45-33 This gets about 17 fps on my code.