build: don't override glsl version, if possible

This commit is contained in:
Andrei Alexeyev 2019-11-27 17:49:15 +02:00
parent 8ccc472e27
commit 0a559da5fe
No known key found for this signature in database
GPG key ID: 363707CD4C7FE8A4
5 changed files with 46 additions and 18 deletions

View file

@ -0,0 +1,13 @@
#version 330 core
#extension GL_ARB_explicit_uniform_location : require
layout(location = 0) in vec2 texCoord;
layout(location = 0) out vec4 outColor;
layout(location = 0) uniform sampler2D tex;
layout(location = 1) uniform vec4 color;
void main(void) {
outColor = texture(tex, texCoord) * color;
}

View file

@ -27,4 +27,5 @@ if angle_enabled and host_machine.system() == 'windows'
bindist_deps += angle_bat
endif
glslc_test_file = files('glslc-test.frag.glsl')
glslc_test_basic_file = files('glslc-test-basic.frag.glsl')
glslc_test_uniform_location_file = files('glslc-test-uniform-location.frag.glsl')

View file

@ -6,6 +6,10 @@
#extension GL_ARB_explicit_uniform_location : require
#endif
#if defined(SPIRV)
#extension GL_ARB_separate_shader_objects : require
#endif
#define LOC(l) layout(location = l)
#if defined(GL_ARB_explicit_uniform_location) || __VERSION__ >= 430
@ -14,7 +18,7 @@
#define UNIFORM(l) uniform
#endif
#if __VERSION__ >= 420
#if __VERSION__ >= 420 || defined(SPIRV)
#define IN(l) LOC(l) in
#define OUT(l) LOC(l) out
#else

View file

@ -100,15 +100,8 @@ essl_targets = []
glslc_args = [
# '-fauto-bind-uniforms',
# '-fauto-map-locations',
# XXX: glslc currently doesn't support ARB_explicit_uniform_location, so we have
# to force a standard that supports it natively to check for location overlaps.
'-std=430core',
# TODO: somehow shut up that annoying warning caused by forcing glsl version.
# '-Werror',
'--target-env=opengl',
'-DSPIRV',
]
glslc_depfile_args = [
@ -163,26 +156,43 @@ if validate_glsl != 'false'
if not glslc_command.found() and validate_glsl == 'true'
glslc_command = subproject('shaderc').get_variable('glslc_native')
glslc_args += '-Werror'
validate_glsl = true
elif glslc_command.found()
test_result = run_command(glslc_command,
glslc_args,
glslc_frag_args,
glslc_test_file,
'-o',
join_paths(meson.build_root(), 'glslc-test.spv')
glslc_test_uniform_location_file,
'-o', '-',
capture : false
)
if test_result.returncode() == 0
glslc_args += '-Werror'
validate_glsl = true
else
warning(test_result.stderr())
glslc_args += '-std=430core'
warning('glslc does not support GL_ARB_explicit_uniform_location, forcing shader version to 430core as a workaround.\n\n@0@'.format(test_result.stderr()))
if validate_glsl == 'auto'
warning('glslc test failed, you probably have an incompatible version. GLSL validation will be disabled.')
validate_glsl = false
test_result = run_command(glslc_command,
glslc_args,
glslc_frag_args,
glslc_test_basic_file,
'-o', '-',
capture : false
)
if test_result.returncode() == 0
validate_glsl = true
else
error('glslc test failed, you probably have an incompatible version.')
warning(test_result.stderr())
if validate_glsl == 'auto'
warning('glslc test failed, you probably have an incompatible version. GLSL validation will be disabled.')
validate_glsl = false
else
error('glslc test failed, you probably have an incompatible version.')
endif
endif
endif
else