Skip to content

Commit

Permalink
build: featurize validate_glsl
Browse files Browse the repository at this point in the history
  • Loading branch information
Akaricchi committed Dec 16, 2022
1 parent 7d76484 commit b393077
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
4 changes: 2 additions & 2 deletions meson_options.txt
Expand Up @@ -122,8 +122,8 @@ option(

option(
'validate_glsl',
type : 'combo',
choices : ['auto', 'true', 'false'],
type : 'feature',
deprecated : {'true' : 'enabled', 'false' : 'disabled'},
description : 'Enable validation of GLSL shaders (requires glslc)'
)

Expand Down
36 changes: 19 additions & 17 deletions resources/00-taisei.pkgdir/shader/meson.build
Expand Up @@ -153,28 +153,30 @@ spvc_vert_args = [
'--stage', 'vert',
]

if ['emscripten', 'nx'].contains(host_machine.system())
validate_glsl = 'true'
transpile_glsl = true
else
validate_glsl = get_option('validate_glsl')
transpile_glsl = false
transpile_glsl = (host_machine.system() in ['emscripten', 'nx'])
opt_validate_glsl = get_option('validate_glsl')

if opt_validate_glsl.disabled() and transpile_glsl
error('GLSL validation can\'t be disabled on this platform')
endif

force_vendored_shader_tools = get_option('force_vendored_shader_tools')
force_validate_glsl = (
opt_validate_glsl.enabled() or
transpile_glsl or
(force_vendored_shader_tools and opt_validate_glsl.allowed())
)

if force_vendored_shader_tools and validate_glsl != 'false'
validate_glsl = 'true'
endif
validate_glsl = false

if validate_glsl != 'false'
if opt_validate_glsl.allowed()
if force_vendored_shader_tools
glslc_command = disabler()
else
glslc_command = find_program('glslc', required : false)
endif

if not glslc_command.found() and validate_glsl == 'true'
if not glslc_command.found() and force_validate_glsl
glslc_command = subproject('shaderc').get_variable('glslc_native')
glslc_args += '-Werror'
validate_glsl = true
Expand Down Expand Up @@ -209,12 +211,12 @@ if validate_glsl != 'false'
else
warning(test_result.stderr())

if validate_glsl == 'auto'
warning('Basic glslc test failed, you probably have a broken/incompatible version. GLSL validation will be disabled.')
validate_glsl = false
else
if force_validate_glsl
error('Basic glslc test failed, you probably have a broken/incompatible version.')
endif

warning('Basic glslc test failed, you probably have a broken/incompatible version. GLSL validation will be disabled.')
validate_glsl = false
endif
else
warning('GLSL validation or translation requested, but glslc was not found')
Expand All @@ -234,10 +236,10 @@ if validate_glsl != 'false'

glslc_args += ['-Os', '-g']
endif
else
validate_glsl = false
endif

transpile_glsl = transpile_glsl and validate_glsl

# @begin validate
if validate_glsl
foreach src : glsl_files
Expand Down

0 comments on commit b393077

Please sign in to comment.