diff --git a/.github/workflows/presubmit.yml b/.github/workflows/presubmit.yml index a2a480ea1f..cceed76817 100644 --- a/.github/workflows/presubmit.yml +++ b/.github/workflows/presubmit.yml @@ -9,108 +9,6 @@ on: - main jobs: - build-desktop-mac: - name: build-mac - runs-on: macos-14-xlarge - steps: - - uses: actions/checkout@v4.1.6 - with: - fetch-depth: 0 - - uses: ./.github/actions/mac-prereq - - name: Run build script - run: | - cd build/mac && printf "y" | ./build.sh presubmit - - name: Test material parser - run: | - out/cmake-release/filament/test/test_material_parser - - build-desktop-linux: - name: build-linux - runs-on: ubuntu-22.04-16core - steps: - - uses: actions/checkout@v4.1.6 - with: - fetch-depth: 0 - - uses: ./.github/actions/linux-prereq - - name: Run build script - run: | - cd build/linux && printf "y" | ./build.sh presubmit - - name: Test material parser - run: | - out/cmake-release/filament/test/test_material_parser - - build-windows: - name: build-windows - runs-on: windows-2022-32core - steps: - - uses: actions/checkout@v4.1.6 - with: - fetch-depth: 0 - - name: Run build script - run: | - build\windows\build-github.bat presubmit - shell: cmd - - build-android: - name: build-android - runs-on: 'ubuntu-24.04-16core' - steps: - - uses: actions/checkout@v4.1.6 - with: - fetch-depth: 0 - - uses: ./.github/actions/linux-prereq - - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: '17' - - name: Run build script - # Only build 1 64 bit target during presubmit to cut down build times during presubmit - # Continuous builds will build everything - run: | - cd build/android && printf "y" | ./build.sh presubmit arm64-v8a - - build-ios: - name: build-iOS - runs-on: macos-14-xlarge - steps: - - uses: actions/checkout@v4.1.6 - with: - fetch-depth: 0 - - uses: ./.github/actions/mac-prereq - - name: Run build script - run: | - cd build/ios && printf "y" | ./build.sh presubmit - - name: Build iOS samples - run: | - cd build/ios && ./build-samples.sh presubmit - - build-web: - name: build-web - runs-on: 'ubuntu-24.04-16core' - steps: - - uses: actions/checkout@v4.1.6 - with: - fetch-depth: 0 - - uses: ./.github/actions/linux-prereq - - uses: ./.github/actions/web-prereq - - name: Run build script - run: | - cd build/web && printf "y" | ./build.sh presubmit - - validate-docs: - name: validate-docs - runs-on: 'ubuntu-24.04-4core' - steps: - - uses: actions/checkout@v4.1.6 - with: - fetch-depth: 0 - - id: get_commit_msg - uses: ./.github/actions/get-commit-msg - - name: Check for manual edits to /docs - run: | - COMMIT_ID=$(echo "${{ steps.get_commit_msg.outputs.msg }}" | head -n 1 | sed "s/commit //g") - bash docs_src/build/presubmit_check.sh ${COMMIT_ID} - test-renderdiff: name: test-renderdiff runs-on: macos-14-xlarge @@ -122,6 +20,7 @@ jobs: uses: ./.github/actions/get-commit-msg - uses: ./.github/actions/mac-prereq - uses: ./.github/actions/get-mesa + - uses: ./.github/actions/get-vulkan-sdk - name: Prerequisites run: | pip install tifffile numpy @@ -129,29 +28,30 @@ jobs: - name: Render and compare id: render_compare run: | - TEST_DIR=test/renderdiff - source ${TEST_DIR}/src/preamble.sh - start_ - GOLDEN_BRANCH=$(echo "${{ steps.get_commit_msg.outputs.msg }}" | python3 ${TEST_DIR}/src/commit_msg.py) - bash ${TEST_DIR}/generate.sh && \ - python3 ${TEST_DIR}/src/golden_manager.py \ - --branch=${GOLDEN_BRANCH} \ - --output=${GOLDEN_OUTPUT_DIR} + vulkaninfo + # TEST_DIR=test/renderdiff + # source ${TEST_DIR}/src/preamble.sh + # start_ + # GOLDEN_BRANCH=$(echo "${{ steps.get_commit_msg.outputs.msg }}" | python3 ${TEST_DIR}/src/commit_msg.py) + # bash ${TEST_DIR}/generate.sh && \ + # python3 ${TEST_DIR}/src/golden_manager.py \ + # --branch=${GOLDEN_BRANCH} \ + # --output=${GOLDEN_OUTPUT_DIR} # Note that we need to upload the output even if comparison fails, so we undo `set -ex` - end_ + # end_ - python3 ${TEST_DIR}/src/compare.py \ - --src=${GOLDEN_OUTPUT_DIR} \ - --dest=${RENDER_OUTPUT_DIR} \ - --out=${DIFF_OUTPUT_DIR} 2>&1 | tee compare_output.txt + # python3 ${TEST_DIR}/src/compare.py \ + # --src=${GOLDEN_OUTPUT_DIR} \ + # --dest=${RENDER_OUTPUT_DIR} \ + # --out=${DIFF_OUTPUT_DIR} 2>&1 | tee compare_output.txt - if grep "Failed" compare_output.txt > /dev/null; then - DELIMITER="EOF_FILE_CONTENT_$(date +%s)" # Using timestamp to make it more unique - echo "err<<$DELIMITER" >> "$GITHUB_OUTPUT" - cat compare_output.txt >> "$GITHUB_OUTPUT" - echo "$DELIMITER" >> "$GITHUB_OUTPUT" - fi + # if grep "Failed" compare_output.txt > /dev/null; then + # DELIMITER="EOF_FILE_CONTENT_$(date +%s)" # Using timestamp to make it more unique + # echo "err<<$DELIMITER" >> "$GITHUB_OUTPUT" + # cat compare_output.txt >> "$GITHUB_OUTPUT" + # echo "$DELIMITER" >> "$GITHUB_OUTPUT" + # fi - uses: actions/upload-artifact@v4 with: name: presubmit-renderdiff-result @@ -164,36 +64,191 @@ jobs: exit 1 fi - validate-wgsl-webgpu: - name: validate-wgsl-webgpu - runs-on: 'ubuntu-24.04-8core' - steps: - - uses: actions/checkout@v4.1.6 - with: - fetch-depth: 0 - - uses: ./.github/actions/linux-prereq - - name: Run build script - run: ./build.sh -W debug test_filamat filament - - name: Run test - run: ./out/cmake-debug/libs/filamat/test_filamat --gtest_filter=MaterialCompiler.Wgsl* + # build-desktop-mac: + # name: build-mac + # runs-on: macos-14-xlarge + # steps: + # - uses: actions/checkout@v4.1.6 + # with: + # fetch-depth: 0 + # - uses: ./.github/actions/mac-prereq + # - name: Run build script + # run: | + # cd build/mac && printf "y" | ./build.sh presubmit + # - name: Test material parser + # run: | + # out/cmake-release/filament/test/test_material_parser - test-code-correctness: - name: test-code-correctness - runs-on: 'macos-14-xlarge' - steps: - - uses: actions/checkout@v4.1.6 - with: - fetch-depth: 0 - - uses: ./.github/actions/mac-prereq - - name: Install clang-tidy and deps - run: | - pip install pyyaml - brew install llvm@${GITHUB_LLVM_VERSION} - sudo ln -s "$(brew --prefix llvm)@${GITHUB_LLVM_VERSION}/bin/clang-tidy" "/usr/local/bin/clang-tidy" - - name: Run build script - # We need to build before clang-tidy can run analysis - run: | - # This will build for all three desktop backends on mac - ./build.sh -p desktop debug gltf_viewer - - name: Run test - run: bash test/code-correctness/test.sh + # build-desktop-linux: + # name: build-linux + # runs-on: ubuntu-22.04-16core + # steps: + # - uses: actions/checkout@v4.1.6 + # with: + # fetch-depth: 0 + # - uses: ./.github/actions/linux-prereq + # - name: Run build script + # run: | + # cd build/linux && printf "y" | ./build.sh presubmit + # - name: Test material parser + # run: | + # out/cmake-release/filament/test/test_material_parser + + # build-windows: + # name: build-windows + # runs-on: windows-2022-32core + # steps: + # - uses: actions/checkout@v4.1.6 + # with: + # fetch-depth: 0 + # - name: Run build script + # run: | + # build\windows\build-github.bat presubmit + # shell: cmd + + # build-android: + # name: build-android + # runs-on: 'ubuntu-24.04-16core' + # steps: + # - uses: actions/checkout@v4.1.6 + # with: + # fetch-depth: 0 + # - uses: ./.github/actions/linux-prereq + # - uses: actions/setup-java@v3 + # with: + # distribution: 'temurin' + # java-version: '17' + # - name: Run build script + # # Only build 1 64 bit target during presubmit to cut down build times during presubmit + # # Continuous builds will build everything + # run: | + # cd build/android && printf "y" | ./build.sh presubmit arm64-v8a + + # build-ios: + # name: build-iOS + # runs-on: macos-14-xlarge + # steps: + # - uses: actions/checkout@v4.1.6 + # with: + # fetch-depth: 0 + # - uses: ./.github/actions/mac-prereq + # - name: Run build script + # run: | + # cd build/ios && printf "y" | ./build.sh presubmit + # - name: Build iOS samples + # run: | + # cd build/ios && ./build-samples.sh presubmit + + # build-web: + # name: build-web + # runs-on: 'ubuntu-24.04-16core' + # steps: + # - uses: actions/checkout@v4.1.6 + # with: + # fetch-depth: 0 + # - uses: ./.github/actions/linux-prereq + # - uses: ./.github/actions/web-prereq + # - name: Run build script + # run: | + # cd build/web && printf "y" | ./build.sh presubmit + + # validate-docs: + # name: validate-docs + # runs-on: 'ubuntu-24.04-4core' + # steps: + # - uses: actions/checkout@v4.1.6 + # with: + # fetch-depth: 0 + # - id: get_commit_msg + # uses: ./.github/actions/get-commit-msg + # - name: Check for manual edits to /docs + # run: | + # COMMIT_ID=$(echo "${{ steps.get_commit_msg.outputs.msg }}" | head -n 1 | sed "s/commit //g") + # bash docs_src/build/presubmit_check.sh ${COMMIT_ID} + + # test-renderdiff: + # name: test-renderdiff + # runs-on: macos-14-xlarge + # steps: + # - uses: actions/checkout@v4.1.6 + # with: + # fetch-depth: 0 + # - id: get_commit_msg + # uses: ./.github/actions/get-commit-msg + # - uses: ./.github/actions/mac-prereq + # - uses: ./.github/actions/get-mesa + # - name: Prerequisites + # run: | + # pip install tifffile numpy + # shell: bash + # - name: Render and compare + # id: render_compare + # run: | + # TEST_DIR=test/renderdiff + # source ${TEST_DIR}/src/preamble.sh + # start_ + # GOLDEN_BRANCH=$(echo "${{ steps.get_commit_msg.outputs.msg }}" | python3 ${TEST_DIR}/src/commit_msg.py) + # bash ${TEST_DIR}/generate.sh && \ + # python3 ${TEST_DIR}/src/golden_manager.py \ + # --branch=${GOLDEN_BRANCH} \ + # --output=${GOLDEN_OUTPUT_DIR} + + # # Note that we need to upload the output even if comparison fails, so we undo `set -ex` + # end_ + + # python3 ${TEST_DIR}/src/compare.py \ + # --src=${GOLDEN_OUTPUT_DIR} \ + # --dest=${RENDER_OUTPUT_DIR} \ + # --out=${DIFF_OUTPUT_DIR} 2>&1 | tee compare_output.txt + + # if grep "Failed" compare_output.txt > /dev/null; then + # DELIMITER="EOF_FILE_CONTENT_$(date +%s)" # Using timestamp to make it more unique + # echo "err<<$DELIMITER" >> "$GITHUB_OUTPUT" + # cat compare_output.txt >> "$GITHUB_OUTPUT" + # echo "$DELIMITER" >> "$GITHUB_OUTPUT" + # fi + # - uses: actions/upload-artifact@v4 + # with: + # name: presubmit-renderdiff-result + # path: ./out/renderdiff + # - name: Compare result + # run: | + # ERROR_STR="${{ steps.render_compare.outputs.err }}" + # if [ -n "${ERROR_STR}" ]; then + # echo "${ERROR_STR}" + # exit 1 + # fi + + # validate-wgsl-webgpu: + # name: validate-wgsl-webgpu + # runs-on: 'ubuntu-24.04-8core' + # steps: + # - uses: actions/checkout@v4.1.6 + # with: + # fetch-depth: 0 + # - uses: ./.github/actions/linux-prereq + # - name: Run build script + # run: ./build.sh -W debug test_filamat filament + # - name: Run test + # run: ./out/cmake-debug/libs/filamat/test_filamat --gtest_filter=MaterialCompiler.Wgsl* + + # test-code-correctness: + # name: test-code-correctness + # runs-on: 'macos-14-xlarge' + # steps: + # - uses: actions/checkout@v4.1.6 + # with: + # fetch-depth: 0 + # - uses: ./.github/actions/mac-prereq + # - name: Install clang-tidy and deps + # run: | + # pip install pyyaml + # brew install llvm@${GITHUB_LLVM_VERSION} + # sudo ln -s "$(brew --prefix llvm)@${GITHUB_LLVM_VERSION}/bin/clang-tidy" "/usr/local/bin/clang-tidy" + # - name: Run build script + # # We need to build before clang-tidy can run analysis + # run: | + # # This will build for all three desktop backends on mac + # ./build.sh -p desktop debug gltf_viewer + # - name: Run test + # run: bash test/code-correctness/test.sh diff --git a/build/common/get-mesa.sh b/build/common/get-mesa.sh index cfe38a9e2a..2c63d22557 100755 --- a/build/common/get-mesa.sh +++ b/build/common/get-mesa.sh @@ -137,6 +137,9 @@ if [[ "$OS_NAME" == "Darwin" ]]; then # This is necessary to be able to build vk (lavapipe) on macOS. Doesn't seem like a real dependency. sed -I '' "s/error('Vulkan drivers require dri3 for X11 support')//g" meson.build + # This is to properly link lib-xcb-present on the mac build (though we won't be drawing to any + # real hardware surface). + sed -I '' "s/dep_xcb_present = null_dep/dep_xcb_present = dependency('xcb-present')/g" meson.build fi # -Dosmesa=true => builds OSMesa, which is an offscreen GL context diff --git a/test/renderdiff/generate.sh b/test/renderdiff/generate.sh index 38802e0d3a..62c72dc4f3 100755 --- a/test/renderdiff/generate.sh +++ b/test/renderdiff/generate.sh @@ -55,7 +55,8 @@ function end_render_() { start_render_ && \ python3 ${RENDERDIFF_TEST_DIR}/src/render.py \ --gltf_viewer="$(pwd)/out/cmake-debug/samples/gltf_viewer" \ - --test=${RENDERDIFF_TEST_DIR}/tests/presubmit.json \ - --output_dir=${RENDER_OUTPUT_DIR} \ - --opengl_lib=${MESA_LIB_DIR} && \ + --test="${RENDERDIFF_TEST_DIR}/tests/presubmit.json" \ + --output_dir="${RENDER_OUTPUT_DIR}" \ + --opengl_lib="${MESA_LIB_DIR}" \ + --vk_icd="${MESA_VK_ICD_PATH}" && \ end_render_ diff --git a/test/renderdiff/src/preamble.sh b/test/renderdiff/src/preamble.sh index be108a71c5..bbf200d09e 100644 --- a/test/renderdiff/src/preamble.sh +++ b/test/renderdiff/src/preamble.sh @@ -29,6 +29,7 @@ if [[ "$os_name" == "Linux" ]]; then MESA_LIB_DIR="${MESA_DIR}lib/x86_64-linux-gnu" elif [[ "$os_name" == "Darwin" ]]; then MESA_LIB_DIR="${MESA_DIR}lib" + MESA_VK_ICD_PATH="${MESA_DIR}share/vulkan/icd.d/lvp_icd.aarch64.json" else echo "Unsupported platform for renderdiff tests" exit 1 diff --git a/test/renderdiff/src/render.py b/test/renderdiff/src/render.py index fb81f8a658..9367527237 100644 --- a/test/renderdiff/src/render.py +++ b/test/renderdiff/src/render.py @@ -26,15 +26,21 @@ from golden_manager import GoldenManager from image_diff import same_image from results import RESULT_OK, RESULT_FAILED -def _render_single_model(gltf_viewer, test_json_path, named_output_dir, test_name, backend, model, model_path, opengl_lib): - env = None +def _render_single_model(gltf_viewer, test_json_path, named_output_dir, + test_name, backend, model, model_path, opengl_lib, vk_icd): + env = {} if backend == 'opengl' and opengl_lib and os.path.isdir(opengl_lib): - env = { + env |= { 'LD_LIBRARY_PATH': opengl_lib, # for macOS 'DYLD_LIBRARY_PATH': opengl_lib, } + if backend == 'vulkan' and os.path.exists(vk_icd): + env |= { + 'VK_ICD_FILENAMES': vk_icd, + } + out_name = f'{test_name}.{backend}.{model}' test_desc = out_name @@ -91,13 +97,15 @@ def _render_test_config(gltf_viewer, f.write(f'[{test.to_filament_format()}]') for backend in test_config.backends: + if backend == 'vulkan': + assert vk_icd, "VK ICD must be specified when testing vulkan backend" for model in test.models: model_path = os.path.abspath(test_config.models[model]) futures.append( executor.submit(_render_single_model, gltf_viewer_abs, test_json_path, named_output_dir, test.name, backend, model, model_path, - opengl_lib)) + opengl_lib, vk_icd)) for future in concurrent.futures.as_completed(futures): results.append(future.result()) diff --git a/test/renderdiff/tests/presubmit.json b/test/renderdiff/tests/presubmit.json index 4ddde454c0..8570305f74 100644 --- a/test/renderdiff/tests/presubmit.json +++ b/test/renderdiff/tests/presubmit.json @@ -1,6 +1,6 @@ { "name": "presubmit", - "backends": ["opengl"], + "backends": ["opengl", "vulkan"], "model_search_paths": ["third_party/models"], "presets": [ {