Skip to content
Snippets Groups Projects
Commit 270c5d67 authored by Ludovico de Nittis's avatar Ludovico de Nittis :palm_tree:
Browse files

check-vulkan: Bundle the required shaders using GResource


Bundling the shaders makes it easier to ship the relocatable version of
the Vulkan helper.

It also fixes the issue reported in #62.

Fixes: #62

Signed-off-by: default avatarLudovico de Nittis <ludovico.denittis@collabora.com>
parent e1cc2c9f
No related tags found
1 merge request!258WIP check-vulkan: Bundle the required shaders using GResource
Pipeline #9722 passed
...@@ -664,15 +664,19 @@ create_shader_module (VkDevice device, ...@@ -664,15 +664,19 @@ create_shader_module (VkDevice device,
VkShaderModule *shader_module, VkShaderModule *shader_module,
GError **error) GError **error)
{ {
g_autofree gchar *shader_data = NULL; const gchar *shader_data = NULL;
g_autoptr(GBytes) bytes = NULL;
gsize size; gsize size;
g_return_val_if_fail (filename != NULL, FALSE); g_return_val_if_fail (filename != NULL, FALSE);
g_return_val_if_fail (shader_module != NULL, FALSE); g_return_val_if_fail (shader_module != NULL, FALSE);
if (!g_file_get_contents (filename, &shader_data, &size, error)) bytes = g_resources_lookup_data (filename, G_RESOURCE_LOOKUP_FLAGS_NONE, error);
if (bytes == NULL)
return FALSE; return FALSE;
shader_data = g_bytes_get_data (bytes, &size);
VkShaderModuleCreateInfo create_info = VkShaderModuleCreateInfo create_info =
{ {
.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
...@@ -692,16 +696,9 @@ create_graphics_pipeline (VulkanPhysicalDeviceProperties *dev_props, ...@@ -692,16 +696,9 @@ create_graphics_pipeline (VulkanPhysicalDeviceProperties *dev_props,
{ {
g_autofree gchar *vert_path = NULL; g_autofree gchar *vert_path = NULL;
g_autofree gchar *frag_path = NULL; g_autofree gchar *frag_path = NULL;
g_autofree gchar *base_path = NULL;
g_return_val_if_fail (dev_props != NULL, FALSE);
base_path = g_strdup (getenv ("SRT_DATA_PATH"));
if (base_path == NULL)
base_path = g_path_get_dirname (argv0);
vert_path = g_build_filename (base_path, "shaders", "/vert.spv", NULL); vert_path = g_build_filename ("/com", "valvesoftware", "steam-runtime-tools", "shader", "vert.spv", NULL);
frag_path = g_build_filename (base_path, "shaders", "/frag.spv", NULL); frag_path = g_build_filename ("/com", "valvesoftware", "steam-runtime-tools", "shader", "frag.spv", NULL);
VkShaderModule vert_shader_module; VkShaderModule vert_shader_module;
VkShaderModule frag_shader_module; VkShaderModule frag_shader_module;
......
...@@ -76,21 +76,10 @@ executable( ...@@ -76,21 +76,10 @@ executable(
# a game with no special linking would be able to use VDPAU. # a game with no special linking would be able to use VDPAU.
) )
executable( shaders = []
multiarch + '-check-vulkan',
'check-vulkan.c',
dependencies : [glib, gio_unix, libglnx_dep, libsteamrt_dep, json_glib, vulkan, xcb],
include_directories : project_include_dirs,
install : true,
install_dir : pkglibexecdir,
# Use the adjacent libsteam-runtime-tools and json-glib, ignoring
# LD_LIBRARY_PATH even if set
build_rpath : pkglibexec_rpath,
install_rpath : pkglibexec_rpath,
)
foreach shader : ['frag', 'vert'] foreach shader : ['frag', 'vert']
custom_target( shaders += custom_target(
shader + '.spv', shader + '.spv',
build_by_default : true, build_by_default : true,
command : [ command : [
...@@ -101,16 +90,31 @@ foreach shader : ['frag', 'vert'] ...@@ -101,16 +90,31 @@ foreach shader : ['frag', 'vert']
], ],
input : 'shader.' + shader, input : 'shader.' + shader,
output : shader + '.spv', output : shader + '.spv',
install : true,
install_dir : join_paths(
get_option('prefix'),
get_option('libexecdir'),
'steam-runtime-tools-' + api_major,
'shaders',
)
) )
endforeach endforeach
shader_resources = gnome.compile_resources(
'shader-resources',
'shader.gresource.xml',
source_dir: meson.current_build_dir(),
dependencies: shaders,
c_name: 'shader',
)
executable(
multiarch + '-check-vulkan',
'check-vulkan.c',
shader_resources,
dependencies : [glib, gio_unix, libglnx_dep, libsteamrt_dep, json_glib, vulkan, xcb],
include_directories : project_include_dirs,
install : true,
install_dir : pkglibexecdir,
# Use the adjacent libsteam-runtime-tools and json-glib, ignoring
# LD_LIBRARY_PATH even if set
build_rpath : pkglibexec_rpath,
install_rpath : pkglibexec_rpath,
)
executable( executable(
multiarch + '-check-gl', multiarch + '-check-gl',
'check-gl.cpp', 'check-gl.cpp',
......
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/com/valvesoftware/steam-runtime-tools/shader">
<file>frag.spv</file>
<file>vert.spv</file>
</gresource>
</gresources>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment