mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2025-12-25 00:10:10 +01:00
A Vulkan renderer for weston, based on the GL renderer. The goal is to impose the least requirements as possible on Vulkan implementations, as to allow even Vulkan 1.0 (or early development) drivers to run a Wayland compositor. Any additional features or extensions are made optional if possible. Currently supports drm, wayland, x11 and headless backends. As of this implementation, this is still considered an experimental renderer. Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
57 lines
1.2 KiB
GLSL
57 lines
1.2 KiB
GLSL
#version 450
|
|
|
|
layout(binding = 1) uniform _ubo {
|
|
uniform vec4 unicolor;
|
|
uniform float view_alpha;
|
|
} ubo;
|
|
layout(binding = 2) uniform sampler2D tex;
|
|
|
|
layout(location = 1) in vec2 v_texcoord;
|
|
|
|
layout(location = 0) out vec4 fragcolor;
|
|
|
|
layout(constant_id = 0) const int c_variant = 0;
|
|
layout(constant_id = 1) const bool c_input_is_premult = false;
|
|
|
|
#define PIPELINE_VARIANT_RGBA 1
|
|
#define PIPELINE_VARIANT_RGBX 2
|
|
#define PIPELINE_VARIANT_SOLID 3
|
|
#define PIPELINE_VARIANT_EXTERNAL 4
|
|
|
|
vec4
|
|
sample_input_texture()
|
|
{
|
|
if (c_variant == PIPELINE_VARIANT_SOLID)
|
|
return ubo.unicolor;
|
|
|
|
if (c_variant == PIPELINE_VARIANT_EXTERNAL ||
|
|
c_variant == PIPELINE_VARIANT_RGBA ||
|
|
c_variant == PIPELINE_VARIANT_RGBX) {
|
|
vec4 color;
|
|
|
|
color = texture(tex, v_texcoord);
|
|
|
|
if (c_variant == PIPELINE_VARIANT_RGBX)
|
|
color.a = 1.0;
|
|
|
|
return color;
|
|
}
|
|
|
|
/* Never reached, bad variant value. */
|
|
return vec4(1.0, 0.3, 1.0, 1.0);
|
|
}
|
|
|
|
void main() {
|
|
vec4 color;
|
|
|
|
/* Electrical (non-linear) RGBA values, may be premult or not */
|
|
color = sample_input_texture();
|
|
|
|
/* Ensure pre-multiplied for blending */
|
|
if (!c_input_is_premult)
|
|
color.rgb *= color.a;
|
|
|
|
color *= ubo.view_alpha;
|
|
|
|
fragcolor = color;
|
|
}
|