MSL: Conditionally validate MSL 2.2 shaders.

Travis CI Xcode image does not support MSL 2.2 yet (beta), so just do
local validation for now.
This commit is contained in:
Hans-Kristian Arntzen 2019-06-17 16:06:14 +02:00
parent 026a167549
commit be1e27a6e5

View File

@ -90,6 +90,21 @@ def print_msl_compiler_version():
except OSError as e: except OSError as e:
if (e.errno != errno.ENOENT): # Ignore xcrun not found error if (e.errno != errno.ENOENT): # Ignore xcrun not found error
raise raise
except subprocess.CalledProcessError:
pass
def msl_compiler_supports_22():
try:
subprocess.check_call(['xcrun', '--sdk', 'macosx', 'metal', '-x', 'metal', '-std=macos-metal2.2', '-'],
stdin = subprocess.DEVNULL, stdout = subprocess.DEVNULL, stderr = subprocess.DEVNULL)
print('Current SDK supports MSL 2.2. Enabling validation for MSL 2.2 shaders.')
return True
except OSError as e:
print('Failed to check if MSL 2.2 is not supported. It probably is not.')
return False
except subprocess.CalledProcessError:
print('Current SDK does NOT support MSL 2.2. Disabling validation for MSL 2.2 shaders.')
return False
def path_to_msl_standard(shader): def path_to_msl_standard(shader):
if '.ios.' in shader: if '.ios.' in shader:
@ -578,7 +593,10 @@ def test_shader_msl(stats, shader, args, paths):
# executable from Xcode using args: `--msl --entry main --output msl_path spirv_path`. # executable from Xcode using args: `--msl --entry main --output msl_path spirv_path`.
# print('SPRIV shader: ' + spirv) # print('SPRIV shader: ' + spirv)
if not args.force_no_external_validation: shader_is_msl22 = 'msl22' in shader
skip_validation = shader_is_msl22 and (not args.msl22)
if (not args.force_no_external_validation) and (not skip_validation):
validate_shader_msl(shader, args.opt) validate_shader_msl(shader, args.opt)
remove_file(spirv) remove_file(spirv)
@ -722,6 +740,7 @@ def main():
if args.msl: if args.msl:
print_msl_compiler_version() print_msl_compiler_version()
args.msl22 = msl_compiler_supports_22()
backend = 'glsl' backend = 'glsl'
if (args.msl or args.metal): if (args.msl or args.metal):