From e6c31a02fdf6aa9dfa201fd5ff7cefaf2c0fbfb9 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Thu, 22 Apr 2021 10:30:18 +0200 Subject: [PATCH] gpu: [compute] cache and re-use drawing operations from the previous frame MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The compute renderer is more expensive to run than the old renderer on low-end GPUs, and even more so on CPUs. To ensure good performance regardless of the end-user device, this change implements automatic re-use of content rendered in the frame before the current. The basic idea is that every drawing operation (PaintOp), along with its transform and clipping, can be hashed and efficiently looked up. A naïve caching approach is then to rasterize every operation to separate sections of several large texture atlases, turning a cache hit into a very cheap texture copy. However, for scenes with lots of overlapping operations, the resulting texture memory from separating the operations would be much larger than the memory for just the window framebuffer. So instead of caching individual operations, this change caches layers, which are sequences of drawing operations. It starts by putting all operations into a single layer. Then, if the subsequent frame re-uses a sub-sequence of that larger layer, it is split. For example, consider a UI similar to the kitchen sample: Hello, Gio