Commit a7674a99 authored by Niklas Haas's avatar Niklas Haas

spirv: compat for older shaderc versions

Since there's no better way to check for the existence of this value
other than by literally probing the header during the build step, we
introduce a new "private" config.h for internal checks like this. (Which
the user is unlikely to ever care about)
parent 96e0dad1
......@@ -26,6 +26,7 @@
#include "ta/talloc.h"
#include "config.h"
#include "config_internal.h"
#include "pl_assert.h"
// Include all of the symbols that should be public in a way that marks them
......
......@@ -4,6 +4,23 @@ fixver = '0'
version = majorver + '.' + apiver + '.' + fixver
# Configuration
conf_public = configuration_data()
conf_internal = configuration_data()
conf_public.set('majorver', majorver)
conf_public.set('apiver', apiver)
conf_public.set('fixver', fixver)
conf_public.set_quoted('version', 'v' + version)
## Update PL_VERSION with `git describe` information if available
git = find_program('git', required: false)
if git.found()
gitdesc = run_command(git, 'describe')
if gitdesc.returncode() == 0
conf_public.set_quoted('version', gitdesc.stdout().strip())
endif
endif
c_opts = [
'-D_ISOC99_SOURCE', '-D_GNU_SOURCE', '-D_XOPEN_SOURCE=700',
'-U__STRICT_ANSI__', '-fvisibility=hidden',
......@@ -123,6 +140,28 @@ if glslang_found
endif
endif
# Work-arounds for shaderc braindeath
shaderc_names = [
'shaderc_shared',
'shaderc_combined',
'shaderc',
]
shaderc = disabler()
foreach n : shaderc_names
if not shaderc.found()
shaderc = cc.find_library(n, required: get_option('shaderc'))
endif
endforeach
if shaderc.found()
conf_internal.set('SHADERC_HAS_PERF', cc.has_header_symbol(
'shaderc/shaderc.h',
'shaderc_optimization_level_performance',
dependencies: shaderc,
))
endif
# Optional dependencies / components
components = [
{
......@@ -154,22 +193,6 @@ components = [
}
]
# Configuration
conf = configuration_data()
conf.set('majorver', majorver)
conf.set('apiver', apiver)
conf.set('fixver', fixver)
conf.set_quoted('version', 'v' + version)
## Update PL_VERSION with `git describe` information if available
git = find_program('git', required: false)
if git.found()
gitdesc = run_command(git, 'describe')
if gitdesc.returncode() == 0
conf.set_quoted('version', gitdesc.stdout().strip())
endif
endif
# Build process
defs = ''
comps = configuration_data()
......@@ -203,14 +226,19 @@ if comps.has('vulkan') and not (comps.has('shaderc') or comps.has('glslang'))
'compile GLSL to SPIR-V (needed by the Vulkan API)!')
endif
# Generate the config.h file
conf.set('extra_defs', defs)
# Generate the config headers
conf_public.set('extra_defs', defs)
configure_file(
input: 'config.h.in',
output: 'config.h',
install_dir: 'include/libplacebo',
configuration: conf,
configuration: conf_public,
)
configure_file(
output: 'config_internal.h',
configuration: conf_internal
)
# Build process
......
......@@ -45,8 +45,13 @@ static bool shaderc_init(struct spirv_compiler *spirv)
if (!p->opts)
goto error;
#ifdef SHADERC_HAS_PERF
shaderc_compile_options_set_optimization_level(p->opts,
shaderc_optimization_level_performance);
#else
shaderc_compile_options_set_optimization_level(p->opts,
shaderc_optimization_level_size);
#endif
int ver, rev;
shaderc_get_spv_version(&ver, &rev);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment