Compare commits

...

2 Commits

Author SHA1 Message Date
Erico Nunes
e4f609e421 Merge branch 'simple-vulkan' into 'main'
Draft: clients/simple-vulkan: New Vulkan client example

See merge request wayland/weston!1379
2024-06-25 21:33:46 +00:00
Erico Nunes
a6ba64bbc4 clients/simple-vulkan: New Vulkan client example
Example to serve as a reference of a basic pure Wayland client using
Vulkan, contained in a single source file and with a minimal set of
dependencies.
It heavily borrows from weston-simple-egl being a reference for EGL
and GLES Wayland clients. The source code aims to stay similar to
simple-egl.c.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
2024-01-19 16:48:36 +00:00
4 changed files with 1926 additions and 0 deletions

View File

@ -172,6 +172,40 @@ simple_clients = [
},
]
dep_vulkan = dependency('vulkan', required: false)
prog_glslang = find_program('glslangValidator', required : false)
if dep_vulkan.found() and prog_glslang.found()
gen = generator(prog_glslang, output : '@PLAINNAME@.spv.h',
arguments : [ '@INPUT@', '--quiet', '-V', '-x', '-o', '@OUTPUT@' ] )
spirv_files = gen.process('simple-vulkan.vert', 'simple-vulkan.frag')
simple_clients += {
'name': 'vulkan',
'sources': [
'simple-vulkan.c',
spirv_files,
fractional_scale_v1_client_protocol_h,
fractional_scale_v1_protocol_c,
tearing_control_v1_client_protocol_h,
tearing_control_v1_protocol_c,
viewporter_client_protocol_h,
viewporter_protocol_c,
xdg_shell_client_protocol_h,
xdg_shell_protocol_c,
],
'dep_objs': [
dep_vulkan,
dep_libm,
dep_libshared,
dep_matrix_c,
dep_wayland_client,
],
'deps': [ 'vulkan', 'wayland-cursor' ],
'options': [ 'renderer-gl' ]
}
endif
foreach t : simple_clients
if simple_build_all or simple_clients_enabled.contains(t.get('name'))
t_name = 'weston-simple-' + t.get('name')

1866
clients/simple-vulkan.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,9 @@
#version 420 core
layout(location = 0) in vec4 vVaryingColor;
layout(location = 0) out vec4 f_color;
void main()
{
f_color = vVaryingColor;
}

View File

@ -0,0 +1,17 @@
#version 420 core
layout(std140, set = 0, binding = 0) uniform block {
uniform mat4 rotation;
};
layout(location = 0) in vec4 in_position;
layout(location = 1) in vec4 in_color;
layout(location = 0) out vec4 vVaryingColor;
void main()
{
gl_Position = rotation * in_position;
gl_Position.z = 0.0; // Hack to avoid negative z clipping, is there a better way to do this?
vVaryingColor = vec4(in_color.rgba);
}