Support running FXC on Unix-likes as well.
Assumes a wine wrapper script is set up, but should be good enough.
This commit is contained in:
Родитель
ffad50b3c2
Коммит
789fa91987
|
@ -115,11 +115,31 @@ def shader_model_hlsl(shader):
|
|||
else:
|
||||
return None
|
||||
|
||||
def shader_to_win_path(shader):
|
||||
# It's (very) convenient to be able to run HLSL testing in wine on Unix-likes, so support that.
|
||||
try:
|
||||
with subprocess.Popen(['winepath', '-w', shader], stdout = subprocess.PIPE, stderr = subprocess.PIPE) as f:
|
||||
stdout_data, stderr_data = f.communicate()
|
||||
return stdout_data.decode('utf-8')
|
||||
except OSError as oe:
|
||||
if (oe.errno != os.errno.ENOENT): # Ignore not found errors
|
||||
return shader
|
||||
except subprocess.CalledProcessError:
|
||||
raise
|
||||
|
||||
def validate_shader_hlsl(shader):
|
||||
subprocess.check_call(['glslangValidator', '-e', 'main', '-D', '-V', shader])
|
||||
is_asm = '.asm' in shader
|
||||
if (not force_no_external_validation) and (not is_asm) and os.path.exists('fxc'):
|
||||
subprocess.check_call(['fxc', '-nologo', shader_model_hlsl(shader), shader])
|
||||
is_no_fxc = '.nofxc.' in shader
|
||||
if (not force_no_external_validation) and (not is_no_fxc):
|
||||
try:
|
||||
win_path = shader_to_win_path(shader)
|
||||
subprocess.check_call(['fxc', '-nologo', shader_model_hlsl(shader), win_path])
|
||||
except OSError as oe:
|
||||
if (oe.errno != os.errno.ENOENT): # Ignore not found errors
|
||||
raise
|
||||
except subprocess.CalledProcessError:
|
||||
print('Failed compiling HLSL shader:', shader, 'with FXC.')
|
||||
sys.exit(1)
|
||||
|
||||
def shader_to_sm(shader):
|
||||
if '.sm51.' in shader:
|
||||
|
|
Загрузка…
Ссылка в новой задаче