forked from joejulian/gio
e6c31a02fd
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 <Editor> <Line Editor> <Button> <Button> <Button> <ProgressBar> <Checkbox> <Toggle> In the first frame, all of the drawing operations comprising the UI will be stored and cached in a single layer. In the second frame the progress bar will have moved and the renderer splits the UI into three layers: layer A for everything up to (but not including) the progress bar, layer B with just the progress bar, and layer C for the rest. Note that nothing has been re-used yet. In the third frame, the progress bar moves again, and this time layer A and C can be copied from the cache only the progress bar needs redrawing through the compute programs. Signed-off-by: Elias Naur <mail@eliasnaur.com>
25 lines
527 B
GLSL
25 lines
527 B
GLSL
#version 310 es
|
|
|
|
// SPDX-License-Identifier: Unlicense OR MIT
|
|
|
|
precision mediump float;
|
|
|
|
layout(binding = 0) uniform sampler2D tex;
|
|
|
|
layout(location = 0) in vec2 vUV;
|
|
|
|
layout(location = 0) out vec4 fragColor;
|
|
|
|
vec3 sRGBtoRGB(vec3 rgb) {
|
|
bvec3 cutoff = greaterThanEqual(rgb, vec3(0.04045));
|
|
vec3 below = rgb/vec3(12.92);
|
|
vec3 above = pow((rgb + vec3(0.055))/vec3(1.055), vec3(2.4));
|
|
return mix(below, above, cutoff);
|
|
}
|
|
|
|
void main() {
|
|
vec4 texel = texture(tex, vUV);
|
|
texel.rgb = sRGBtoRGB(texel.rgb);
|
|
fragColor = texel;
|
|
}
|