szeged / webrender

A GPU-based renderer for the web
https://doc.servo.org/webrender/
Mozilla Public License 2.0
45 stars 7 forks source link

Reduce the number of buffer allocations #300

Closed zakorgy closed 5 years ago

zakorgy commented 5 years ago

Previously we had vertex and instance buffers for each program, so we had a lot of pending resource if a program was not used frequently. Instead of this we can have one buffer for our main vertices (a quad) for the entire run, and we can store our instance buffers for each frame. Previously our instance buffers had different sizes and could only store data for one specific data stride. Now we have 1 MB large instance buffers which can store the data of different instances with different data strides. Also added an optional buffer for data download with a fixed 10 MB size (wrench doesn't require larger than this), so we don't recreate a buffer every time we read the content of the screen.

The two debug program has their vertex and index buffers still attached to their program, since those are not the essential part of rendering, and if we enable them, they are used in every frame. We can refactor them in a later PR as well.