github: add script and action for getting gltf assets (#9085)

- Script for getting models from glTF-Sample-Assets
- Add support for reading gltf models from a file.
This commit is contained in:
Powei Feng
2025-08-21 15:16:12 -07:00
committed by GitHub
parent 5fd5cd270c
commit 679b08b5db
10 changed files with 136 additions and 9 deletions

View File

@@ -22,6 +22,7 @@ GOLDEN_OUTPUT_DIR="$(pwd)/out/renderdiff/goldens"
RENDERDIFF_TEST_DIR="$(pwd)/test/renderdiff"
MESA_DIR="$(pwd)/mesa/out/"
VENV_DIR="$(pwd)/venv"
GLTF_DIR="$(pwd)/gltf/Models"
BUILD_COMMON_DIR="$(pwd)/build/common"
os_name=$(uname -s)

View File

@@ -44,11 +44,22 @@ class RenderingConfig():
class PresetConfig(RenderingConfig):
def __init__(self, data, existing_models):
RenderingConfig.__init__(self, data)
models = data.get('models')
if models:
self.models = []
def _check(models):
assert _is_list_of_strings(models)
assert all(m in existing_models for m in models)
models = data.get('models')
if models:
_check(models)
self.models = models
model_list_file = data.get('model_list_file')
if model_list_file and os.path.exists(model_list_file):
with open(model_list_file, 'r') as f:
models = list(filter(lambda a: len(a) > 0, map(lambda a: a.strip(), f.read().split('\n'))))
_check(models)
self.models += models
class TestConfig(RenderingConfig):
def __init__(self, data, existing_models, presets):
@@ -105,7 +116,9 @@ class RenderTestConfig():
assert all(path.isdir(p) for p in model_search_paths)
model_paths = list(
chain(*(glob.glob(f'{d}/**/*.glb', recursive=True) for d in model_search_paths)))
chain(*(glob.glob(f'{d}/**/*.glb', recursive=True) for d in model_search_paths))) + \
list(
chain(*(glob.glob(f'{d}/**/*.gltf', recursive=True) for d in model_search_paths)))
# This flatten the output for glob.glob
self.models = {path.splitext(path.basename(model))[0]: model for model in model_paths}