mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-01 22:58:38 -04:00
render/vulkan: add support for RGB565 texture format
Since this does not have a matching _SRGB-type vulkan format, add a new shader variant/pipeline to perform the sRGB->linear texture conversion.
This commit is contained in:
parent
060df4c6c0
commit
3ed69b4946
4 changed files with 78 additions and 8 deletions
|
|
@ -9,8 +9,28 @@ layout(push_constant) uniform UBO {
|
|||
layout(offset = 80) float alpha;
|
||||
} data;
|
||||
|
||||
layout (constant_id = 0) const int TEXTURE_TRANSFORM = 0;
|
||||
|
||||
#define TEXTURE_TRANSFORM_IDENTITY 0
|
||||
#define TEXTURE_TRANSFORM_SRGB 1
|
||||
|
||||
float srgb_to_linear(float x) {
|
||||
return max(x / 12.92, pow((x + 0.055) / 1.055, 2.4));
|
||||
}
|
||||
|
||||
void main() {
|
||||
out_color = textureLod(tex, uv, 0);
|
||||
vec4 val = textureLod(tex, uv, 0);
|
||||
if (TEXTURE_TRANSFORM == TEXTURE_TRANSFORM_SRGB) {
|
||||
out_color = vec4(
|
||||
srgb_to_linear(val.r),
|
||||
srgb_to_linear(val.g),
|
||||
srgb_to_linear(val.b),
|
||||
val.a
|
||||
);
|
||||
} else { // TEXTURE_TRANSFORM_IDENTITY
|
||||
out_color = val;
|
||||
}
|
||||
|
||||
out_color *= data.alpha;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue