mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-22 10:50:15 -10:00
The unsized uniform-buffer fixture uses a Vulkan extension added after the system standalone validator. Running it through the old Vulkan 1.0 profile rejects a legal Uniform/Block runtime array. Its std430 layout also needs the standard uniform-buffer layout feature enabled during independent validation. Use a pinned current SPIRV-Tools validator and matching headers in a dedicated cached CI job. Keep Vulkan 1.0 for ordinary fixtures and Vulkan 1.1 for subgroup operations; apply the extension fixture's required rules only to that module. Do not skip incompatible-validator failures or relax other shaders' checks. Deliberately misalign a member of the emitted UBO and require its rejection. Validation: all 40 emitted SPIR-V modules pass current standalone validation; the corrupted UBO fails alignment validation. Extended compiler and builder contracts pass ASan/UBSan, and all five emitted GLSL programs pass glslang. The pinned setup helper passes cold-source and cached-build runs. No production shader compiler or device-feature admission is changed.
62 lines
2.6 KiB
Python
62 lines
2.6 KiB
Python
#!/usr/bin/env python3
|
|
"""Build the pinned standalone validator without replacing system tools."""
|
|
import argparse
|
|
import os
|
|
from pathlib import Path
|
|
import subprocess
|
|
|
|
TOOLS = '3e73ae769e684f17b283250f803a231a830d45e3'
|
|
HEADERS = '5c6004e758e0c80185ef2cee93ae5c10fa342a5b'
|
|
|
|
|
|
def run(command, **kwargs):
|
|
subprocess.run(command, check=True, **kwargs)
|
|
|
|
|
|
def checkout(path, repository, revision):
|
|
if not path.exists():
|
|
run(['git', 'init', '--quiet', str(path)])
|
|
probe = subprocess.run(['git', '-C', str(path), 'rev-parse', '--verify', 'HEAD'],
|
|
capture_output=True, text=True)
|
|
if probe.returncode:
|
|
# An interrupted initial fetch has no HEAD yet. Resume only that
|
|
# empty repository; never discard a different cached checkout.
|
|
run(['git', '-C', str(path), 'fetch', '--depth=1', repository, revision],
|
|
timeout=180)
|
|
run(['git', '-C', str(path), 'checkout', '--detach', revision])
|
|
head = subprocess.check_output(['git', '-C', str(path), 'rev-parse', 'HEAD'],
|
|
text=True).strip()
|
|
if head != revision:
|
|
raise RuntimeError(f'Unexpected cached source revision: {path}: {head}')
|
|
run(['git', '-C', str(path), 'diff', '--exit-code', 'HEAD', '--'])
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument('--cache-dir', required=True, type=Path)
|
|
parser.add_argument('--jobs', type=int, default=2)
|
|
args = parser.parse_args()
|
|
if not 1 <= args.jobs <= 64:
|
|
parser.error('--jobs must be between 1 and 64')
|
|
root = args.cache_dir.resolve() / TOOLS
|
|
root.mkdir(parents=True, exist_ok=True)
|
|
source, build = root / 'source', root / 'build'
|
|
checkout(source, 'https://github.com/KhronosGroup/SPIRV-Tools.git', TOOLS)
|
|
checkout(source / 'external/spirv-headers',
|
|
'https://github.com/KhronosGroup/SPIRV-Headers.git', HEADERS)
|
|
run(['cmake', '-S', str(source), '-B', str(build), '-G', 'Ninja',
|
|
'-DCMAKE_BUILD_TYPE=Release', '-DSPIRV_SKIP_TESTS=ON',
|
|
'-DSPIRV_SKIP_EXECUTABLES=OFF', '-DSPIRV_WERROR=OFF'], timeout=120)
|
|
run(['cmake', '--build', str(build), '--target', 'spirv-val',
|
|
'-j', str(args.jobs)], timeout=600)
|
|
binary = build / 'tools' / ('spirv-val.exe' if os.name == 'nt' else 'spirv-val')
|
|
run([str(binary), '--version'])
|
|
if os.environ.get('GITHUB_PATH'):
|
|
with open(os.environ['GITHUB_PATH'], 'a', encoding='utf-8') as output:
|
|
output.write(str(binary.parent) + '\n')
|
|
print(f'Validator: {binary}', flush=True)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|