mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-01 22:58:38 -04:00
render/vulkan: allow rendering to non-8-bit buffers
This is implemented by a two-subpass rendering scheme; the first subpass draws (and blends) onto a linear R16G16B16A16_SFLOAT buffer, while the second subpass performs linear->srgb conversion, writing onto the actual output buffer.
This commit is contained in:
parent
8cdc4b7a31
commit
10dd416694
5 changed files with 651 additions and 90 deletions
21
render/vulkan/shaders/output.frag
Normal file
21
render/vulkan/shaders/output.frag
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#version 450
|
||||
|
||||
layout (input_attachment_index = 0, binding = 0) uniform subpassInput in_color;
|
||||
|
||||
layout(location = 0) in vec2 uv;
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
float linear_to_srgb(float x) {
|
||||
return max(min(x * 12.92, 0.04045), 1.055 * pow(x, 1. / 2.4) - 0.055);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 val = subpassLoad(in_color).rgba;
|
||||
out_color = vec4(
|
||||
linear_to_srgb(val.r),
|
||||
linear_to_srgb(val.g),
|
||||
linear_to_srgb(val.b),
|
||||
val.a
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue