mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-02 11:05:39 +00:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9ca6fa064e | ||
|
|
aab15f3146 | ||
|
|
11af78340a |
No files matched your search
@@ -7,7 +7,7 @@ on:
|
||||
push:
|
||||
branches: [main]
|
||||
workflow_run:
|
||||
workflows: [Build APK, Unit tests]
|
||||
workflows: [Build APK]
|
||||
types: [completed]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
|
||||
+115
-2
@@ -349,7 +349,7 @@ jobs:
|
||||
|
||||
build:
|
||||
needs: [source, components, xbox, build-runner]
|
||||
name: Compile APK
|
||||
name: Compile APK and Android tests
|
||||
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }}
|
||||
runs-on: ${{ fromJSON(needs.build-runner.outputs.labels) }}
|
||||
timeout-minutes: 45
|
||||
@@ -507,7 +507,23 @@ jobs:
|
||||
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
||||
BUILD_REF: ${{ github.ref_name }}
|
||||
BUILD_SHA: ${{ github.sha }}
|
||||
run: bash tools/ci/build-label.sh
|
||||
run: |
|
||||
if [[ -n "$(git status --porcelain)" ]]; then
|
||||
tree_state=dirty
|
||||
else
|
||||
tree_state=clean
|
||||
fi
|
||||
echo "DROIDDECK_BUILD_TREE_STATE=$tree_state" >> "$GITHUB_ENV"
|
||||
if [[ -n "$PR_NUMBER" ]]; then
|
||||
label="pr${PR_NUMBER} at ${PR_HEAD_SHA:0:7}"
|
||||
else
|
||||
label="${BUILD_REF} at ${BUILD_SHA:0:7}"
|
||||
fi
|
||||
echo "label=$label" >> "$GITHUB_OUTPUT"
|
||||
echo "DROIDDECK_SOURCE_COMMIT=${PR_HEAD_SHA:-$BUILD_SHA}" >> "$GITHUB_ENV"
|
||||
echo "DROIDDECK_PR_NUMBER=${PR_NUMBER:-0}" >> "$GITHUB_ENV"
|
||||
echo "DROIDDECK_PR_TITLE=${PR_TITLE//$'\n'/ }" >> "$GITHUB_ENV"
|
||||
echo "Build: \`$label\`" >> "$GITHUB_STEP_SUMMARY"
|
||||
|
||||
- name: Rust toolchain for the store engines (aarch64-linux-android)
|
||||
id: rust
|
||||
@@ -718,6 +734,101 @@ jobs:
|
||||
if-no-files-found: ignore
|
||||
overwrite: true
|
||||
|
||||
- name: Resolve the Robolectric version
|
||||
id: robolectric
|
||||
run: |
|
||||
echo "version=$(grep -o "org.robolectric:robolectric:[0-9.]*" app/build.gradle | cut -d: -f3)" >> "$GITHUB_OUTPUT"
|
||||
# Robolectric downloads these from Maven Central on first use without retrying, and 429s fail whole test classes.
|
||||
# The cache path sits beside the workspace because runner homes are at different depths from it, and
|
||||
# actions/cache stores paths relative to the workspace. It is passed as an absolute path: the save action rejects
|
||||
# "..". Runners that keep their own ~/.m2 skip the cache.
|
||||
- name: Place Robolectric's Android jars beside the workspace
|
||||
id: robolectric-jars
|
||||
run: |
|
||||
set -euo pipefail
|
||||
jars="$GITHUB_WORKSPACE/../robolectric-jars"
|
||||
m2="$HOME/.m2/repository/org/robolectric/android-all-instrumented"
|
||||
if [ -d "$m2" ] && [ ! -L "$m2" ]; then
|
||||
echo "cache=false" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
mkdir -p "$jars" "$(dirname "$m2")"
|
||||
jars=$(cd "$jars" && pwd)
|
||||
ln -sfn "$jars" "$m2"
|
||||
echo "path=$jars" >> "$GITHUB_OUTPUT"
|
||||
echo "cache=true" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
- name: Restore Robolectric's Android jars
|
||||
id: robolectric-cache
|
||||
if: steps.robolectric-jars.outputs.cache == 'true'
|
||||
uses: actions/cache/restore@v4
|
||||
with:
|
||||
path: ${{ steps.robolectric-jars.outputs.path }}
|
||||
key: robolectric-android-all-v3-${{ steps.robolectric.outputs.version }}-${{ github.run_id }}
|
||||
restore-keys: robolectric-android-all-v3-${{ steps.robolectric.outputs.version }}-
|
||||
- name: Count the restored Robolectric jars
|
||||
if: steps.robolectric-jars.outputs.cache == 'true'
|
||||
run: echo "ROBOLECTRIC_JARS_BEFORE=$(find "$GITHUB_WORKSPACE/../robolectric-jars" -name '*.jar' | wc -l)" >> "$GITHUB_ENV"
|
||||
- name: Unit tests
|
||||
id: unit-tests
|
||||
env:
|
||||
DROIDDECK_BUILD_LABEL: ${{ steps.build-label.outputs.label }}
|
||||
SGDB_API_KEY: ${{ secrets.SGDB_API_KEY }}
|
||||
run: |
|
||||
set -o pipefail
|
||||
mkdir -p app/build
|
||||
# A Maven 429 fails every test class that needs the missing jar. The jars an attempt did get stay for the next.
|
||||
for wait in 60 180 0; do
|
||||
status=0
|
||||
./gradlew testReleaseUnitTest --console=plain --info --stacktrace -Drobolectric.logging=stderr -PndkVersion="$NDK_VERSION" 2>&1 | tee app/build/unit-tests.log || status=$?
|
||||
if [ "$status" = 0 ] || [ "$wait" = 0 ] || ! grep -Eq '^[[:space:]]*(Caused by: org\.gradle\.internal\.resource\.transport\.http\.HttpErrorStatusCodeException: Could not GET .*https://repo\.maven\.apache\.org/.*Received status code 429 from server|Caused by: java\.io\.IOException: Server returned HTTP response code: 429 for URL: https://repo\.maven\.apache\.org/)' app/build/unit-tests.log; then
|
||||
exit "$status"
|
||||
fi
|
||||
echo "::warning::Maven Central answered 429; running the unit tests again in ${wait}s"
|
||||
sleep "$wait"
|
||||
done
|
||||
|
||||
# actions/cache only saves when the job succeeds, so a run whose tests died on a Maven 429 never filled the cache.
|
||||
# Save the complete jars even after a failed test step, when this run added some; a partial download is dropped first.
|
||||
- name: Save Robolectric's Android jars
|
||||
id: robolectric-jars-final
|
||||
if: always() && steps.robolectric-jars.outputs.cache == 'true'
|
||||
run: |
|
||||
python3 - <<'PY'
|
||||
import glob, os, zipfile
|
||||
root = os.path.join(os.environ['GITHUB_WORKSPACE'], '..', 'robolectric-jars')
|
||||
for f in glob.glob(os.path.join(root, '**', '*'), recursive=True):
|
||||
if not os.path.isfile(f):
|
||||
continue
|
||||
try:
|
||||
ok = f.endswith('.jar') and zipfile.ZipFile(f).testzip() is None
|
||||
except Exception:
|
||||
ok = False
|
||||
if not ok:
|
||||
os.remove(f)
|
||||
PY
|
||||
after=$(find "$GITHUB_WORKSPACE/../robolectric-jars" -name '*.jar' | wc -l)
|
||||
[ "$after" -gt "${ROBOLECTRIC_JARS_BEFORE:-0}" ] && echo "save=true" >> "$GITHUB_OUTPUT" || true
|
||||
- name: Store Robolectric's Android jars
|
||||
if: always() && steps.robolectric-jars-final.outputs.save == 'true'
|
||||
uses: actions/cache/save@v4
|
||||
with:
|
||||
path: ${{ steps.robolectric-jars.outputs.path }}
|
||||
key: robolectric-android-all-v3-${{ steps.robolectric.outputs.version }}-${{ github.run_id }}
|
||||
|
||||
- name: Upload unit test diagnostics
|
||||
id: unit-test-diagnostics
|
||||
if: always() && steps.unit-tests.outcome != 'skipped'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: unit-test-results
|
||||
path: |
|
||||
app/build/unit-tests.log
|
||||
app/build/test-results/testReleaseUnitTest/
|
||||
app/build/reports/tests/testReleaseUnitTest/
|
||||
if-no-files-found: ignore
|
||||
retention-days: 14
|
||||
overwrite: true
|
||||
|
||||
- name: Sign with the testkey (v1 + v2 + v3)
|
||||
run: |
|
||||
set -euo pipefail
|
||||
@@ -773,6 +884,8 @@ jobs:
|
||||
PR: ${{ github.event.pull_request.number }}
|
||||
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||
BUILD_OUTCOME: ${{ steps.build.outcome }}
|
||||
UNIT_TEST_OUTCOME: ${{ steps.unit-tests.outcome }}
|
||||
TEST_DIAGNOSTICS_URL: ${{ steps.unit-test-diagnostics.outputs.artifact-url }}
|
||||
APK_OUTCOME: ${{ steps.apk-upload.outcome }}
|
||||
run: bash tools/release/report-build.sh
|
||||
|
||||
|
||||
@@ -47,13 +47,6 @@ jobs:
|
||||
echo "::error::main ${GITHUB_SHA::7} has no successful Build APK run yet: wait for it, then release"
|
||||
exit 1
|
||||
fi
|
||||
tests=$(gh run list -R "$GITHUB_REPOSITORY" --workflow unit-tests.yml --branch main --commit "$GITHUB_SHA" \
|
||||
--json conclusion,event,headSha -L 20 |
|
||||
jq -r --arg sha "$GITHUB_SHA" '[.[] | select(.headSha == $sha and (.event == "push" or .event == "workflow_dispatch"))][0].conclusion // empty')
|
||||
if [ "$tests" != success ]; then
|
||||
echo "::error::main ${GITHUB_SHA::7} has no passing Unit tests run (${tests:-none yet}): fix or wait for it, then release"
|
||||
exit 1
|
||||
fi
|
||||
variants=$(awk '!/^#/ && NF { print $1 }' tools/release/variants.txt | jq -R . | jq -sc .)
|
||||
echo "run_id=$id" >> "$GITHUB_OUTPUT"
|
||||
echo "variants=$variants" >> "$GITHUB_OUTPUT"
|
||||
|
||||
@@ -1,180 +0,0 @@
|
||||
name: Unit tests
|
||||
run-name: ${{ github.event_name == 'pull_request' && format('unit tests for pr {0} on {1}', github.event.pull_request.number, github.event.pull_request.head.sha) || format('unit tests for {0} on {1}', github.ref_name, github.sha) }}
|
||||
|
||||
# Runs beside Build APK rather than inside it, so a test build is published as soon as the APK compiles.
|
||||
# Build validation folds this workflow's result into the "Build APK" commit status, and Release APKs requires it.
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
paths-ignore:
|
||||
- '**/*.md'
|
||||
- 'LICENSE'
|
||||
- '.gitignore'
|
||||
- 'docs/**'
|
||||
- '.github/ISSUE_TEMPLATE/**'
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
types: [ opened, synchronize, reopened, ready_for_review ]
|
||||
paths-ignore:
|
||||
- '**/*.md'
|
||||
- 'LICENSE'
|
||||
- '.gitignore'
|
||||
- 'docs/**'
|
||||
- '.github/ISSUE_TEMPLATE/**'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
actions: read
|
||||
|
||||
concurrency:
|
||||
group: unit-tests-${{ github.event.pull_request.number || (github.event_name == 'push' && 'main') || github.run_id }}
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' || github.event_name == 'push' }}
|
||||
|
||||
jobs:
|
||||
unit-tests:
|
||||
name: Unit tests
|
||||
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }}
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 45
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
|
||||
fetch-depth: 0
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/docs/releases/media/
|
||||
sparse-checkout-cone-mode: false
|
||||
persist-credentials: false
|
||||
|
||||
- name: Merge onto main
|
||||
if: github.event_name == 'pull_request'
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git config user.name "ci"
|
||||
git config user.email "ci@users.noreply.github.com"
|
||||
git fetch --no-tags origin main
|
||||
git merge-tree --write-tree HEAD FETCH_HEAD >/dev/null || true
|
||||
git merge --no-ff --no-edit FETCH_HEAD || { echo "::error::the pull request conflicts with main; Build APK lists the files"; exit 1; }
|
||||
|
||||
- name: Check out MaliBridge
|
||||
run: git submodule update --init external/MaliBridge
|
||||
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: '17'
|
||||
|
||||
- uses: gradle/actions/setup-gradle@v4
|
||||
with:
|
||||
cache-read-only: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository }}
|
||||
cache-cleanup: ${{ github.event_name == 'pull_request' && 'never' || 'on-success' }}
|
||||
|
||||
- name: Resolve the pinned Android NDK
|
||||
run: bash tools/ci/resolve-ndk.sh
|
||||
|
||||
- name: Set the APK build label
|
||||
id: build-label
|
||||
env:
|
||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
PR_TITLE: ${{ github.event.pull_request.title }}
|
||||
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
||||
BUILD_REF: ${{ github.ref_name }}
|
||||
BUILD_SHA: ${{ github.sha }}
|
||||
run: bash tools/ci/build-label.sh
|
||||
|
||||
- name: Resolve the Robolectric version
|
||||
id: robolectric
|
||||
run: |
|
||||
echo "version=$(grep -o "org.robolectric:robolectric:[0-9.]*" app/build.gradle | cut -d: -f3)" >> "$GITHUB_OUTPUT"
|
||||
# Robolectric downloads these from Maven Central on first use without retrying, and 429s fail whole test classes.
|
||||
# The cache path sits beside the workspace because runner homes are at different depths from it, and
|
||||
# actions/cache stores paths relative to the workspace. It is passed as an absolute path: the save action rejects
|
||||
# "..". Runners that keep their own ~/.m2 skip the cache.
|
||||
- name: Place Robolectric's Android jars beside the workspace
|
||||
id: robolectric-jars
|
||||
run: |
|
||||
set -euo pipefail
|
||||
jars="$GITHUB_WORKSPACE/../robolectric-jars"
|
||||
m2="$HOME/.m2/repository/org/robolectric/android-all-instrumented"
|
||||
if [ -d "$m2" ] && [ ! -L "$m2" ]; then
|
||||
echo "cache=false" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
mkdir -p "$jars" "$(dirname "$m2")"
|
||||
jars=$(cd "$jars" && pwd)
|
||||
ln -sfn "$jars" "$m2"
|
||||
echo "path=$jars" >> "$GITHUB_OUTPUT"
|
||||
echo "cache=true" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
- name: Restore Robolectric's Android jars
|
||||
id: robolectric-cache
|
||||
if: steps.robolectric-jars.outputs.cache == 'true'
|
||||
uses: actions/cache/restore@v4
|
||||
with:
|
||||
path: ${{ steps.robolectric-jars.outputs.path }}
|
||||
key: robolectric-android-all-v3-${{ steps.robolectric.outputs.version }}-${{ github.run_id }}
|
||||
restore-keys: robolectric-android-all-v3-${{ steps.robolectric.outputs.version }}-
|
||||
- name: Count the restored Robolectric jars
|
||||
if: steps.robolectric-jars.outputs.cache == 'true'
|
||||
run: echo "ROBOLECTRIC_JARS_BEFORE=$(find "$GITHUB_WORKSPACE/../robolectric-jars" -name '*.jar' | wc -l)" >> "$GITHUB_ENV"
|
||||
- name: Unit tests
|
||||
id: unit-tests
|
||||
env:
|
||||
DROIDDECK_BUILD_LABEL: ${{ steps.build-label.outputs.label }}
|
||||
SGDB_API_KEY: ${{ secrets.SGDB_API_KEY }}
|
||||
run: |
|
||||
set -o pipefail
|
||||
mkdir -p app/build
|
||||
# A Maven 429 fails every test class that needs the missing jar. The jars an attempt did get stay for the next.
|
||||
for wait in 60 180 0; do
|
||||
status=0
|
||||
./gradlew testReleaseUnitTest --console=plain --info --stacktrace -Drobolectric.logging=stderr -PskipRust=true -PunitTestsOnly=true -PndkVersion="$NDK_VERSION" 2>&1 | tee app/build/unit-tests.log || status=$?
|
||||
if [ "$status" = 0 ] || [ "$wait" = 0 ] || ! grep -Eq '^[[:space:]]*(Caused by: org\.gradle\.internal\.resource\.transport\.http\.HttpErrorStatusCodeException: Could not GET .*https://repo\.maven\.apache\.org/.*Received status code 429 from server|Caused by: java\.io\.IOException: Server returned HTTP response code: 429 for URL: https://repo\.maven\.apache\.org/)' app/build/unit-tests.log; then
|
||||
exit "$status"
|
||||
fi
|
||||
echo "::warning::Maven Central answered 429; running the unit tests again in ${wait}s"
|
||||
sleep "$wait"
|
||||
done
|
||||
|
||||
# actions/cache only saves when the job succeeds, so a run whose tests died on a Maven 429 never filled the cache.
|
||||
# Save the complete jars even after a failed test step, when this run added some; a partial download is dropped first.
|
||||
- name: Save Robolectric's Android jars
|
||||
id: robolectric-jars-final
|
||||
if: always() && steps.robolectric-jars.outputs.cache == 'true'
|
||||
run: |
|
||||
python3 - <<'PY'
|
||||
import glob, os, zipfile
|
||||
root = os.path.join(os.environ['GITHUB_WORKSPACE'], '..', 'robolectric-jars')
|
||||
for f in glob.glob(os.path.join(root, '**', '*'), recursive=True):
|
||||
if not os.path.isfile(f):
|
||||
continue
|
||||
try:
|
||||
ok = f.endswith('.jar') and zipfile.ZipFile(f).testzip() is None
|
||||
except Exception:
|
||||
ok = False
|
||||
if not ok:
|
||||
os.remove(f)
|
||||
PY
|
||||
after=$(find "$GITHUB_WORKSPACE/../robolectric-jars" -name '*.jar' | wc -l)
|
||||
[ "$after" -gt "${ROBOLECTRIC_JARS_BEFORE:-0}" ] && echo "save=true" >> "$GITHUB_OUTPUT" || true
|
||||
- name: Store Robolectric's Android jars
|
||||
if: always() && steps.robolectric-jars-final.outputs.save == 'true'
|
||||
uses: actions/cache/save@v4
|
||||
with:
|
||||
path: ${{ steps.robolectric-jars.outputs.path }}
|
||||
key: robolectric-android-all-v3-${{ steps.robolectric.outputs.version }}-${{ github.run_id }}
|
||||
|
||||
- name: Upload unit test diagnostics
|
||||
id: unit-test-diagnostics
|
||||
if: always() && steps.unit-tests.outcome != 'skipped'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: unit-test-results
|
||||
path: |
|
||||
app/build/unit-tests.log
|
||||
app/build/test-results/testReleaseUnitTest/
|
||||
app/build/reports/tests/testReleaseUnitTest/
|
||||
if-no-files-found: ignore
|
||||
retention-days: 14
|
||||
overwrite: true
|
||||
@@ -7,7 +7,7 @@
|
||||
- For an install-and-look iteration, use `tools/quick_deploy.sh` (build without lint, sign, install, about 30 s). Run `tools/build_local.sh` once to prepare the runtime and again only before a PR. It is not a per-change step.
|
||||
- `tools/build_local.sh` reuses the components a main CI run prepared when every recipe identity matches the local tree (it prints `components: … reusing`). It builds them locally when no usable CI artifact matches (after you change their inputs, or when the lookup fails) or with `DROIDDECK_CI_COMPONENTS=0`.
|
||||
- Helper scripts (`tools/linuxfs/overlay`, `tools/linuxfs/desktop`) are staged on every Gradle build, so editing them needs no `build_local.sh`. After preloads or other runtime components change, the fast loop warns and reuses the old binaries; run `tools/build_local.sh` when those matter. "Missing or changed runtime input" means the prepared files themselves changed: run `tools/build_local.sh` once. Do not revert scripts or copy `app/build` between checkouts; `tools/seed_worktree.sh` seeds a new worktree from the main checkout.
|
||||
- Every build defaults to the NDK in `tools/ci/toolchains.env`, as CI does. CI runs `testReleaseUnitTest` in the `Unit tests` workflow, beside Build APK; when a test fails only in CI, run the release variant locally.
|
||||
- Every build defaults to the NDK in `tools/ci/toolchains.env`, as CI does. CI runs `testReleaseUnitTest`; when a test fails only in CI, run the release variant locally.
|
||||
- Run the tests that cover what you changed, including unchanged tests of code you edited: `./gradlew -PskipRust=true :app:testDebugUnitTest --tests '<class>'` and `python3 -m unittest discover -s tools/tests -p 'test_<area>*.py'`. The full Python suite takes about 9 minutes, and some preload tests fail on any host without zram/ntsync. Leave full runs to CI.
|
||||
- For UI screenshots without a device, run `./gradlew -PskipRust=true :app:testDebugUnitTest --tests '*PreviewRenderTest'` and read `app/build/preview-renders/{handheld,portrait}/`. Add cases per `docs/compose-previews.md`. Check portrait, not just landscape.
|
||||
- After changing `SettingsIndex`, regenerate the doc: `UPDATE_SETTINGS_MAP=1 ./gradlew -PskipRust=true :app:testDebugUnitTest --tests '*SettingsMapTest*'`.
|
||||
@@ -31,7 +31,7 @@
|
||||
- CI builds the PR merged onto `main`. Before pushing, merge or rebase onto `origin/main` and compile: most "works locally" Kotlin failures come from that merge.
|
||||
- Before a PR that touches strings or resources, run `./gradlew :app:lintVitalRelease`. The fast loop skips lint, and lint catches `ExtraTranslation` and missing-locale errors.
|
||||
- Commit messages and PR bodies must not carry `Co-Authored-By` or other bot trailers. `tools/release/check_authorship.py` fails the build on them.
|
||||
- `gh run view --log-failed` truncates the unit-test log, so the failing test may not show. Read the whole job log with `gh api repos/Droid-Deck/DroidDeck/actions/jobs/<job-id>/logs`, or `gh run download <run> -n unit-test-results` from the `Unit tests` workflow run. Don't call a failure a runner problem until you have read it.
|
||||
- `gh run view --log-failed` truncates the unit-test log, so the failing test may not show. Read the whole job log with `gh api repos/Droid-Deck/DroidDeck/actions/jobs/<job-id>/logs`, or `gh run download <run> -n unit-test-results`. Don't call a failure a runner problem until you have read it.
|
||||
- Only these are known flakes worth a `gh run rerun <run> --failed`: `ProtonMenuAutoTest` "Proton work did not finish", Robolectric `HTTP response code: 429` from Maven, `Gradle Test Executor N finished with non-zero exit value 2`, apt mirror and GitHub API rate-limit errors. Treat any other failure as real.
|
||||
- A workflow step that names a script your branch lacks means the branch predates a CI change. Rebase onto `main`.
|
||||
|
||||
|
||||
+1
-5
@@ -82,8 +82,6 @@ def buildBranch = providers.environmentVariable('GITHUB_HEAD_REF').getOrNull()?.
|
||||
?: gitValue(['branch', '--show-current']) ?: ''
|
||||
def escapeJava = { String value -> value.replace('\\', '\\\\').replace('"', '\\"').replace('\n', ' ').replace('\r', ' ') }
|
||||
def ciBuild = providers.environmentVariable('GITHUB_ACTIONS').getOrNull() == 'true'
|
||||
// The Unit tests workflow compiles no APK, so it has no add-on packs to pin.
|
||||
def unitTestsOnly = project.findProperty('unitTestsOnly')?.toString()?.toBoolean() ?: false
|
||||
def releaseSigner = rootProject.file('keystore/release-signer.sha256').text.trim()
|
||||
def commitTime = (gitValue(['show', '-s', '--format=%ct', '--end-of-options', sourceCommit]) ?: '0').with { it.isLong() ? it : '0' }
|
||||
def desktopKde = rootProject.file('tools/desktop-kde/release.env').readLines()
|
||||
@@ -98,12 +96,10 @@ def prootPackPin = rootProject.file('tools/packs/proot/release.env').readLines()
|
||||
def addonPacks = ['proot', 'directaudio', 'tracking', 'xbox', 'comet', 'butler', 'powervr', 'ubisoft', 'rockstar', 'dirt', 'epic'].collectEntries { name ->
|
||||
def pack = file("build/packs/${name}.tar.zst")
|
||||
if (!pack.isFile()) {
|
||||
if (ciBuild && !unitTestsOnly) throw new GradleException("Add-on pack ${pack} is missing: run tools/packs/build.sh app/build/packs")
|
||||
if (ciBuild) throw new GradleException("Add-on pack ${pack} is missing: run tools/packs/build.sh app/build/packs")
|
||||
if (name == 'proot' && prootPackPin.PROOT_PACK_SHA256) {
|
||||
return [(name): [sha256: prootPackPin.PROOT_PACK_SHA256, size: (prootPackPin.PROOT_PACK_SIZE ?: '0') as long]]
|
||||
}
|
||||
// A CI APK pins every pack, and CI_BUILD code assumes that, so the tests see a placeholder pin.
|
||||
if (unitTestsOnly) return [(name): [sha256: '0' * 64, size: 0L]]
|
||||
return [(name): [sha256: '', size: 0L]]
|
||||
}
|
||||
def digest = java.security.MessageDigest.getInstance('SHA-256')
|
||||
|
||||
@@ -205,15 +205,19 @@ int ahb_swapchain_present(struct dmabuf_buffer *b, struct surface *s, int scene_
|
||||
struct droiddeck_dma_buf_sync_file exp = {.flags = DROIDDECK_DMA_BUF_SYNC_READ, .fd = -1};
|
||||
if (dmabuf_fd >= 0 && ioctl(dmabuf_fd, DROIDDECK_DMA_BUF_IOCTL_EXPORT_SYNC_FILE, &exp) == 0 && exp.fd >= 0) {
|
||||
acquire = exp.fd;
|
||||
} else if (dmabuf_fd >= 0) {
|
||||
} else {
|
||||
if (!g_export_failed_logged) {
|
||||
g_export_failed_logged = 1;
|
||||
droiddeck_log("layer", "zero-copy: DMA_BUF_IOCTL_EXPORT_SYNC_FILE failed (%s): waiting for each frame on the CPU instead",
|
||||
strerror(errno));
|
||||
droiddeck_log("layer", "zero-copy: no acquire fence from the game's dma-buf (%s): %s",
|
||||
dmabuf_fd >= 0 ? strerror(errno) : "no dma-buf fd",
|
||||
draw ? "its frames are copied instead" : "it cannot be copied, so each frame is waited for on the CPU");
|
||||
}
|
||||
struct pollfd p = {.fd = dmabuf_fd, .events = POLLIN};
|
||||
int r;
|
||||
do { r = poll(&p, 1, 100); } while (r < 0 && errno == EINTR);
|
||||
if (dmabuf_fd >= 0) {
|
||||
struct pollfd p = {.fd = dmabuf_fd, .events = POLLIN};
|
||||
int r;
|
||||
do { r = poll(&p, 1, 100); } while (r < 0 && errno == EINTR);
|
||||
}
|
||||
if (draw) return -1;
|
||||
}
|
||||
int r = sc_layer_present_ahb(ab->ahb, ab->w, ab->h, acquire, (void *)(uintptr_t)ab->id, scene_w, scene_h, draw,
|
||||
s ? droiddeck_surface_color(s) : NULL, ab->format);
|
||||
|
||||
@@ -2272,6 +2272,69 @@ static void bind_output(struct wl_client *c, void *data, uint32_t ver, uint32_t
|
||||
|
||||
struct draw_list { struct vkp_draw *d; int n, cap; };
|
||||
|
||||
#define ZERO_COPY_FALLBACK_SIGNATURES 32u
|
||||
enum zero_copy_fallback_reason {
|
||||
ZERO_COPY_NO_SURFACE_BUFFER = 1,
|
||||
ZERO_COPY_NO_GRALLOC_AHB = 2,
|
||||
ZERO_COPY_AHB_PRESENT_FAILED = 3
|
||||
};
|
||||
struct zero_copy_fallback_signature {
|
||||
uint32_t reason, format, stride, offset;
|
||||
int width, height;
|
||||
uint64_t modifier;
|
||||
};
|
||||
static struct zero_copy_fallback_signature g_zero_copy_fallbacks[ZERO_COPY_FALLBACK_SIGNATURES];
|
||||
static uint32_t g_zero_copy_fallback_count;
|
||||
static int g_zero_copy_fallback_limit_logged;
|
||||
|
||||
static int zero_copy_fallback_should_log(const struct dmabuf_buffer *b, uint32_t reason) {
|
||||
const struct zero_copy_fallback_signature key = {
|
||||
.reason = reason, .format = b ? b->format : 0,
|
||||
.stride = b && b->n_planes ? b->stride[0] : 0,
|
||||
.offset = b && b->n_planes ? b->offset[0] : 0,
|
||||
.width = b ? b->width : 0, .height = b ? b->height : 0,
|
||||
.modifier = b ? b->modifier : 0};
|
||||
for (uint32_t i = 0; i < g_zero_copy_fallback_count; i++) {
|
||||
const struct zero_copy_fallback_signature *seen = &g_zero_copy_fallbacks[i];
|
||||
if (seen->reason == key.reason && seen->format == key.format && seen->stride == key.stride &&
|
||||
seen->offset == key.offset && seen->width == key.width && seen->height == key.height &&
|
||||
seen->modifier == key.modifier)
|
||||
return 0;
|
||||
}
|
||||
if (g_zero_copy_fallback_count >= ZERO_COPY_FALLBACK_SIGNATURES) {
|
||||
if (!g_zero_copy_fallback_limit_logged) {
|
||||
g_zero_copy_fallback_limit_logged = 1;
|
||||
droiddeck_log("layer", "zero-copy: further fallback diagnostics suppressed after %u distinct buffer signatures",
|
||||
ZERO_COPY_FALLBACK_SIGNATURES);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
g_zero_copy_fallbacks[g_zero_copy_fallback_count++] = key;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void note_zero_copy_fallback(struct surface *s, const struct dmabuf_buffer *b, uint32_t reason,
|
||||
int scene_w, int scene_h, int present_result) {
|
||||
if (!zero_copy_fallback_should_log(b, reason)) return;
|
||||
char name[160] = "unknown surface";
|
||||
if (s) describe(s, name, sizeof(name));
|
||||
if (reason == ZERO_COPY_NO_SURFACE_BUFFER) {
|
||||
droiddeck_log("layer", "zero-copy: layer candidate %s has no associated Wayland surface buffer; using the layer-copy path",
|
||||
name);
|
||||
} else {
|
||||
droiddeck_log("layer", "zero-copy: %s buffer %c%c%c%c %dx%d stride %u offset %u modifier 0x%llx %s; "
|
||||
"scene %dx%d will use the layer-copy path (direct-present result %d)",
|
||||
name, b->format & 0xff, (b->format >> 8) & 0xff, (b->format >> 16) & 0xff,
|
||||
(b->format >> 24) & 0xff, b->width, b->height,
|
||||
b->n_planes ? b->stride[0] : 0, b->n_planes ? b->offset[0] : 0,
|
||||
(unsigned long long)b->modifier,
|
||||
reason == ZERO_COPY_NO_GRALLOC_AHB
|
||||
? "has no registered gralloc AHardwareBuffer"
|
||||
: "has a registered gralloc AHardwareBuffer but direct presentation failed",
|
||||
scene_w, scene_h, present_result);
|
||||
}
|
||||
}
|
||||
|
||||
static int add_cursor(struct draw_list *dl, int scene_w);
|
||||
|
||||
static struct vkp_image *surface_image(struct surface *s) {
|
||||
@@ -2391,17 +2454,53 @@ static int black_fill_below(const struct draw_list *dl, int n) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define LAYER_CANDIDATE_DIAGNOSTICS 32u
|
||||
static unsigned g_layer_candidate_diag_count;
|
||||
static int g_layer_candidate_diag_limit;
|
||||
|
||||
static void note_layer_candidate_skip(const struct vkp_draw *d, int index, int reason,
|
||||
int scene_w, int scene_h) {
|
||||
static int seen[LAYER_CANDIDATE_DIAGNOSTICS][8];
|
||||
const int key[8] = {index, reason, scene_w, scene_h, d->dx, d->dy, d->dw, d->dh};
|
||||
for (unsigned i = 0; i < g_layer_candidate_diag_count; i++)
|
||||
if (!memcmp(seen[i], key, sizeof(key))) return;
|
||||
if (g_layer_candidate_diag_count >= LAYER_CANDIDATE_DIAGNOSTICS) {
|
||||
if (!g_layer_candidate_diag_limit++) droiddeck_log("layer", "zero-copy: further candidate-rejection details suppressed after %u signatures",
|
||||
LAYER_CANDIDATE_DIAGNOSTICS);
|
||||
return;
|
||||
}
|
||||
memcpy(seen[g_layer_candidate_diag_count++], key, sizeof(key));
|
||||
const char *why = reason == 1 ? "translucent draw" :
|
||||
reason == 2 ? "image is not DMA-BUF" :
|
||||
reason == 3 ? "source rectangle is outside/invalid" :
|
||||
reason == 4 ? "draw rectangle is outside scene or invalid" :
|
||||
"not fullscreen and no black backing below";
|
||||
droiddeck_log("layer", "zero-copy: candidate draw %d rejected: %s; scene %dx%d, dst %dx%d at %d,%d, src %.2f,%.2f %.2fx%.2f, image %dx%d",
|
||||
index, why, scene_w, scene_h, d->dw, d->dh, d->dx, d->dy,
|
||||
d->sx, d->sy, d->sw, d->sh, vkp_image_width(d->img), vkp_image_height(d->img));
|
||||
}
|
||||
|
||||
static int layer_candidate(const struct draw_list *dl, int scene_w, int scene_h) {
|
||||
for (int i = dl->n - 1; i >= 0 && i >= dl->n - 2; i--) {
|
||||
const struct vkp_draw *d = &dl->d[i];
|
||||
if (d->blend) continue;
|
||||
if (!vkp_image_is_dmabuf(d->img)) continue;
|
||||
if (d->blend) { note_layer_candidate_skip(d, i, 1, scene_w, scene_h); continue; }
|
||||
if (!vkp_image_is_dmabuf(d->img)) { note_layer_candidate_skip(d, i, 2, scene_w, scene_h); continue; }
|
||||
if (d->sx < 0 || d->sy < 0 || d->sw < 1.0f || d->sh < 1.0f ||
|
||||
d->sx + d->sw >= vkp_image_width(d->img) + 1.0f ||
|
||||
d->sy + d->sh >= vkp_image_height(d->img) + 1.0f) continue;
|
||||
d->sy + d->sh >= vkp_image_height(d->img) + 1.0f) {
|
||||
note_layer_candidate_skip(d, i, 3, scene_w, scene_h);
|
||||
continue;
|
||||
}
|
||||
if (d->dx == 0 && d->dy == 0 && d->dw == scene_w && d->dh == scene_h) return i;
|
||||
if (d->dx < 0 || d->dy < 0 || d->dw <= 0 || d->dh <= 0 || d->dx + d->dw > scene_w ||
|
||||
d->dy + d->dh > scene_h || !black_fill_below(dl, i)) continue;
|
||||
d->dy + d->dh > scene_h) {
|
||||
note_layer_candidate_skip(d, i, 4, scene_w, scene_h);
|
||||
continue;
|
||||
}
|
||||
if (!black_fill_below(dl, i)) {
|
||||
note_layer_candidate_skip(d, i, 5, scene_w, scene_h);
|
||||
continue;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
@@ -2422,6 +2521,56 @@ static void note_copy_scene(const struct draw_list *dl, int scene_w, int scene_h
|
||||
vkp_image_is_dmabuf(t->img) ? "GPU" : "memory", t->blend ? ", translucent" : "");
|
||||
}
|
||||
|
||||
static struct surface *surface_for_image(const struct vkp_image *img);
|
||||
|
||||
static void note_layer_candidate_rejected(const struct draw_list *dl, int scene_w, int scene_h) {
|
||||
static int seen[32][14];
|
||||
static unsigned seen_count;
|
||||
static int limit_logged;
|
||||
static time_t window_start;
|
||||
struct timespec now_ts;
|
||||
const struct vkp_draw *a = dl->n > 0 ? &dl->d[dl->n - 1] : NULL;
|
||||
const struct vkp_draw *b = dl->n > 1 ? &dl->d[dl->n - 2] : NULL;
|
||||
struct surface *sa = a ? surface_for_image(a->img) : NULL;
|
||||
struct surface *sb = b ? surface_for_image(b->img) : NULL;
|
||||
const int signature[14] = {
|
||||
dl->n, scene_w, scene_h,
|
||||
a ? a->dw : 0, a ? a->dh : 0,
|
||||
a ? vkp_image_width(a->img) : 0, a ? vkp_image_height(a->img) : 0,
|
||||
a ? vkp_image_is_dmabuf(a->img) : 0, a ? a->blend : 0, sa && sa->dmabuf_buf ? 1 : 0,
|
||||
b ? b->dw : 0, b ? b->dh : 0, b ? vkp_image_is_dmabuf(b->img) : 0, sb && sb->dmabuf_buf ? 1 : 0
|
||||
};
|
||||
clock_gettime(CLOCK_MONOTONIC, &now_ts);
|
||||
if (!window_start || now_ts.tv_sec - window_start >= 30) {
|
||||
seen_count = 0;
|
||||
limit_logged = 0;
|
||||
window_start = now_ts.tv_sec;
|
||||
}
|
||||
for (unsigned i = 0; i < seen_count; i++)
|
||||
if (!memcmp(signature, seen[i], sizeof(signature))) return;
|
||||
if (seen_count >= 32) {
|
||||
if (!limit_logged++) droiddeck_log("layer", "zero-copy: further fullscreen-candidate rejection details suppressed after 32 signatures in 30 seconds");
|
||||
return;
|
||||
}
|
||||
memcpy(seen[seen_count++], signature, sizeof(signature));
|
||||
char below[48];
|
||||
if (b)
|
||||
snprintf(below, sizeof(below), "%s %dx%d",
|
||||
vkp_image_is_dmabuf(b->img) ? "DMA-BUF" : "non-DMA-BUF", b->dw, b->dh);
|
||||
else
|
||||
snprintf(below, sizeof(below), "none");
|
||||
droiddeck_log("layer", "zero-copy: no eligible fullscreen DMA-BUF layer candidate: scene %dx%d, %d draws; "
|
||||
"top draw %dx%d at %d,%d image %dx%d %s%s surface=%s dmabuf=%s; "
|
||||
"draw below %s",
|
||||
scene_w, scene_h, dl->n, a ? a->dw : 0, a ? a->dh : 0, a ? a->dx : 0, a ? a->dy : 0,
|
||||
a ? vkp_image_width(a->img) : 0, a ? vkp_image_height(a->img) : 0,
|
||||
a && vkp_image_is_dmabuf(a->img) ? "DMA-BUF" : "non-DMA-BUF",
|
||||
a && a->blend ? " blended" : "",
|
||||
sa ? "associated" : "unassociated",
|
||||
sa && sa->dmabuf_buf ? "yes" : "no",
|
||||
below);
|
||||
}
|
||||
|
||||
static struct surface *surface_for_image(const struct vkp_image *img) {
|
||||
struct surface *s;
|
||||
wl_list_for_each(s, &g_surfaces, link)
|
||||
@@ -2430,16 +2579,56 @@ static struct surface *surface_for_image(const struct vkp_image *img) {
|
||||
}
|
||||
|
||||
static struct surface *ahb_layer_only_candidate(int scene_w, int scene_h) {
|
||||
static struct {
|
||||
const struct surface *surface;
|
||||
int reason, scene_w, scene_h, w, h, buf_w, buf_h, x, y, src_set, dst_set, children;
|
||||
} seen[32];
|
||||
static unsigned seen_count;
|
||||
static int limit_logged;
|
||||
struct surface *s;
|
||||
int w, h;
|
||||
int w = 0, h = 0, reason = 0;
|
||||
if (wl_list_empty(&g_toplevels)) return NULL;
|
||||
s = wl_container_of(g_toplevels.prev, s, toplevel_link);
|
||||
if (!s->dmabuf_buf || s->dmabuf_buf->img || !ahb_swapchain_has_ahb(s->dmabuf_buf)) return NULL;
|
||||
if ((g_desktop && !s->placed) || s->x != 0 || s->y != 0 || s->src_set || s->dst_set) return NULL;
|
||||
if (!wl_list_empty(&s->children)) return NULL;
|
||||
if (g_hide_shell && !strcmp(client_name(wl_resource_get_client(s->resource)), "explorer.exe")) return NULL;
|
||||
if (!s->dmabuf_buf) reason = 1;
|
||||
else if (s->dmabuf_buf->img) reason = 2;
|
||||
else if (!ahb_swapchain_has_ahb(s->dmabuf_buf)) reason = 3;
|
||||
else if ((g_desktop && !s->placed) || s->x != 0 || s->y != 0 || s->src_set || s->dst_set) reason = 4;
|
||||
else if (!wl_list_empty(&s->children)) reason = 5;
|
||||
else if (g_hide_shell && !strcmp(client_name(wl_resource_get_client(s->resource)), "explorer.exe")) reason = 6;
|
||||
surface_size(s, &w, &h);
|
||||
if (w != scene_w || h != scene_h || s->buf_w != scene_w || s->buf_h != scene_h) return NULL;
|
||||
if (!reason && (w != scene_w || h != scene_h || s->buf_w != scene_w || s->buf_h != scene_h)) reason = 7;
|
||||
if (reason) {
|
||||
int found = 0;
|
||||
for (unsigned i = 0; i < seen_count; i++) {
|
||||
if (seen[i].surface == s && seen[i].reason == reason && seen[i].scene_w == scene_w &&
|
||||
seen[i].scene_h == scene_h && seen[i].w == w && seen[i].h == h &&
|
||||
seen[i].buf_w == s->buf_w && seen[i].buf_h == s->buf_h && seen[i].x == s->x &&
|
||||
seen[i].y == s->y && seen[i].src_set == s->src_set && seen[i].dst_set == s->dst_set &&
|
||||
seen[i].children == !wl_list_empty(&s->children)) { found = 1; break; }
|
||||
}
|
||||
if (!found && seen_count < 32) {
|
||||
seen[seen_count].surface = s; seen[seen_count].reason = reason;
|
||||
seen[seen_count].scene_w = scene_w; seen[seen_count].scene_h = scene_h;
|
||||
seen[seen_count].w = w; seen[seen_count].h = h; seen[seen_count].buf_w = s->buf_w; seen[seen_count].buf_h = s->buf_h;
|
||||
seen[seen_count].x = s->x; seen[seen_count].y = s->y; seen[seen_count].src_set = s->src_set;
|
||||
seen[seen_count].dst_set = s->dst_set; seen[seen_count].children = !wl_list_empty(&s->children);
|
||||
seen_count++;
|
||||
const char *why = reason == 1 ? "no DMA-BUF buffer" :
|
||||
reason == 2 ? "buffer is already importable by Vulkan" :
|
||||
reason == 3 ? "no registered gralloc AHardwareBuffer" :
|
||||
reason == 4 ? "surface is positioned/cropped/scaled" :
|
||||
reason == 5 ? "surface has child surfaces" :
|
||||
reason == 6 ? "hidden shell surface" : "surface or buffer dimensions differ from scene";
|
||||
char name[160]; describe(s, name, sizeof(name));
|
||||
droiddeck_log("layer", "zero-copy: AHardwareBuffer-only candidate rejected: %s; %s, scene %dx%d, surface %dx%d at %d,%d, buffer %dx%d, crop=%d destination=%d children=%d",
|
||||
why, name, scene_w, scene_h, w, h, s->x, s->y, s->buf_w, s->buf_h,
|
||||
s->src_set, s->dst_set, !wl_list_empty(&s->children));
|
||||
} else if (!found && !limit_logged) {
|
||||
limit_logged = 1;
|
||||
droiddeck_log("layer", "zero-copy: further AHardwareBuffer-only candidate diagnostics suppressed after 32 signatures");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -2882,7 +3071,10 @@ static void render_scene(void) {
|
||||
struct surface *ls = li >= 0 ? surface_for_image(dl.d[li].img) : NULL;
|
||||
const struct vkp_draw *ld = li >= 0 ? &dl.d[li] : NULL;
|
||||
if (li < 0) ls = layer_only;
|
||||
if (g_zero_copy && li < 0 && !ls && !blocked && !cardboard) note_copy_scene(&dl, w, h, cursor_on);
|
||||
if (g_zero_copy && li < 0 && !ls && !blocked && !cardboard) {
|
||||
if (!cursor_on && !bfi) note_layer_candidate_rejected(&dl, w, h);
|
||||
note_copy_scene(&dl, w, h, cursor_on);
|
||||
}
|
||||
if (cardboard) ls = NULL;
|
||||
if (cursor_on) ls = NULL;
|
||||
if (bfi) ls = NULL;
|
||||
@@ -2910,6 +3102,14 @@ static void render_scene(void) {
|
||||
r = generated >= 0 ? 0 : -1;
|
||||
else if (generated >= 0 && !(fx_on && li >= 0) && ls && ls->dmabuf_buf && ahb_swapchain_has_ahb(ls->dmabuf_buf))
|
||||
r = ahb_swapchain_present(ls->dmabuf_buf, ls, w, h, ld);
|
||||
if (!fg_pass && generated >= 0 && !fx_on && !framegen && r != 0) {
|
||||
if (!ls || !ls->dmabuf_buf)
|
||||
note_zero_copy_fallback(ls, NULL, ZERO_COPY_NO_SURFACE_BUFFER, w, h, r);
|
||||
else if (!ahb_swapchain_has_ahb(ls->dmabuf_buf))
|
||||
note_zero_copy_fallback(ls, ls->dmabuf_buf, ZERO_COPY_NO_GRALLOC_AHB, w, h, r);
|
||||
else
|
||||
note_zero_copy_fallback(ls, ls->dmabuf_buf, ZERO_COPY_AHB_PRESENT_FAILED, w, h, r);
|
||||
}
|
||||
if (r == 0 && !fg_pass) g_zero_copy_shown = ls;
|
||||
else settle_unwaited();
|
||||
if (!fg_pass && generated >= 0 && r != 0 && li >= 0)
|
||||
|
||||
@@ -62,8 +62,40 @@ struct entry {
|
||||
static struct wl_list g_entries;
|
||||
static struct wl_event_loop *g_loop;
|
||||
static uint64_t g_next_id = 1;
|
||||
static int g_refused_logged;
|
||||
static int g_ubwc_promised;
|
||||
|
||||
#define DISPLAY_BUFFER_MISMATCH_SIGNATURES 64u
|
||||
struct display_buffer_mismatch_signature {
|
||||
uint32_t kind, format, stride, offset;
|
||||
int width, height;
|
||||
uint64_t modifier;
|
||||
};
|
||||
static struct display_buffer_mismatch_signature g_mismatch_signatures[DISPLAY_BUFFER_MISMATCH_SIGNATURES];
|
||||
static uint32_t g_mismatch_signature_count;
|
||||
static int g_mismatch_limit_logged;
|
||||
|
||||
static int mismatch_should_log(const struct dmabuf_buffer *b, uint32_t kind) {
|
||||
const struct display_buffer_mismatch_signature key = {
|
||||
.kind = kind, .format = b->format, .stride = b->stride[0], .offset = b->offset[0],
|
||||
.width = b->width, .height = b->height, .modifier = b->modifier};
|
||||
for (uint32_t i = 0; i < g_mismatch_signature_count; i++) {
|
||||
const struct display_buffer_mismatch_signature *seen = &g_mismatch_signatures[i];
|
||||
if (seen->kind == key.kind && seen->format == key.format && seen->stride == key.stride &&
|
||||
seen->offset == key.offset && seen->width == key.width && seen->height == key.height &&
|
||||
seen->modifier == key.modifier)
|
||||
return 0;
|
||||
}
|
||||
if (g_mismatch_signature_count >= DISPLAY_BUFFER_MISMATCH_SIGNATURES) {
|
||||
if (!g_mismatch_limit_logged) {
|
||||
g_mismatch_limit_logged = 1;
|
||||
droiddeck_log("layer", "display buffers: further mismatch diagnostics suppressed after %u distinct buffer signatures",
|
||||
DISPLAY_BUFFER_MISMATCH_SIGNATURES);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
g_mismatch_signatures[g_mismatch_signature_count++] = key;
|
||||
return 1;
|
||||
}
|
||||
static int g_ubwc_probed[2];
|
||||
|
||||
static uint32_t ahb_format_of(uint32_t drm, uint64_t modifier) {
|
||||
@@ -238,16 +270,51 @@ static void handle_alloc(struct peer *p, const struct display_buffers_request *q
|
||||
} else {
|
||||
if (ahb) AHardwareBuffer_release(ahb);
|
||||
fd = -1;
|
||||
if (sized && wanted && (compressed || !g_refused_logged)) {
|
||||
g_refused_logged = 1;
|
||||
droiddeck_log(compressed ? "error" : "layer", "display buffers: no gralloc buffer matches pid %d's %ux%u "
|
||||
"%c%c%c%c %s layout (stride %u bytes, pixels at %u, %llu bytes; gralloc's layout has pixels at "
|
||||
"%llu, %llu bytes): %s", (int)p->pid, q->width, q->height,
|
||||
q->format & 0xff, (q->format >> 8) & 0xff, (q->format >> 16) & 0xff, (q->format >> 24) & 0xff,
|
||||
compressed ? "UBWC" : "linear", q->stride, q->offset, (unsigned long long)q->size,
|
||||
(unsigned long long)(compressed ? ubwc_meta_size(q->width, q->height) : 0),
|
||||
(unsigned long long)(compressed ? ubwc_size(q->width, q->height, q->stride) : q->size),
|
||||
compressed ? "its compressed frames cannot be shown" : "its frames keep the copy path");
|
||||
static struct {
|
||||
pid_t pid;
|
||||
uint32_t width, height, format, stride, offset, reason;
|
||||
uint64_t size, modifier;
|
||||
} refused[32];
|
||||
static unsigned refused_count;
|
||||
static int refused_limit_logged;
|
||||
uint32_t reason = !sized ? 1u : !sane ? 2u : !wanted ? 3u :
|
||||
!ahb_swapchain_advertised() ? 4u :
|
||||
p->count >= DISPLAY_BUFFERS_MAX_PER_CLIENT ? 5u : 6u;
|
||||
int seen = 0;
|
||||
for (unsigned i = 0; i < refused_count; i++) {
|
||||
if (refused[i].pid == p->pid && refused[i].width == q->width && refused[i].height == q->height &&
|
||||
refused[i].format == q->format && refused[i].stride == q->stride && refused[i].offset == q->offset &&
|
||||
refused[i].size == q->size && refused[i].modifier == q->modifier && refused[i].reason == reason) {
|
||||
seen = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!seen && refused_count < 32) {
|
||||
refused[refused_count].pid = p->pid;
|
||||
refused[refused_count].width = q->width;
|
||||
refused[refused_count].height = q->height;
|
||||
refused[refused_count].format = q->format;
|
||||
refused[refused_count].stride = q->stride;
|
||||
refused[refused_count].offset = q->offset;
|
||||
refused[refused_count].size = q->size;
|
||||
refused[refused_count].modifier = q->modifier;
|
||||
refused[refused_count].reason = reason;
|
||||
refused_count++;
|
||||
const char *why = reason == 1 ? "invalid dimensions, format, or stride" :
|
||||
reason == 2 ? "size/offset/layout sanity check failed" :
|
||||
reason == 3 ? "zero-copy or UBWC offering is disabled" :
|
||||
reason == 4 ? "AHardwareBuffer swapchain is not advertised" :
|
||||
reason == 5 ? "per-client allocation limit reached" :
|
||||
"gralloc allocation/fd/size validation failed";
|
||||
droiddeck_log(compressed ? "error" : "layer",
|
||||
"display buffers: allocation refused for pid %d: %s; request %ux%u %c%c%c%c %s stride=%u offset=%u size=%llu modifier=0x%llx (client has %d allocations)",
|
||||
(int)p->pid, why, q->width, q->height,
|
||||
q->format & 0xff, (q->format >> 8) & 0xff, (q->format >> 16) & 0xff, (q->format >> 24) & 0xff,
|
||||
compressed ? "UBWC" : "linear", q->stride, q->offset,
|
||||
(unsigned long long)q->size, (unsigned long long)q->modifier, p->count);
|
||||
} else if (!seen && !refused_limit_logged) {
|
||||
refused_limit_logged = 1;
|
||||
droiddeck_log("layer", "display buffers: further allocation-refusal diagnostics suppressed after 32 signatures");
|
||||
}
|
||||
}
|
||||
if (reply(p, &r, fd) != 0 && e) entry_free(e);
|
||||
@@ -299,9 +366,18 @@ static int on_listen(int fd, uint32_t mask, void *data) {
|
||||
}
|
||||
|
||||
void display_buffers_match(struct wl_client *c, struct wl_resource *buffer, struct dmabuf_buffer *b) {
|
||||
static int invalid_logged;
|
||||
struct stat st;
|
||||
struct entry *e;
|
||||
if (!g_loop || wl_list_empty(&g_entries) || b->n_planes != 1 || b->offset[0] != 0 || fstat(b->fd[0], &st) != 0) return;
|
||||
if (!g_loop || wl_list_empty(&g_entries)) return;
|
||||
if (b->n_planes != 1 || b->offset[0] != 0 || fstat(b->fd[0], &st) != 0) {
|
||||
if (!invalid_logged) {
|
||||
invalid_logged = 1;
|
||||
droiddeck_log("layer", "display buffers: cannot associate %s's DMA-BUF with gralloc (plane count %u; expected one plane at offset 0, or fstat failed)",
|
||||
droiddeck_client_name(c), b->n_planes);
|
||||
}
|
||||
return;
|
||||
}
|
||||
wl_list_for_each(e, &g_entries, link) {
|
||||
if (e->dev != st.st_dev || e->ino != st.st_ino) continue;
|
||||
AHardwareBuffer_Desc d;
|
||||
@@ -311,11 +387,27 @@ void display_buffers_match(struct wl_client *c, struct wl_resource *buffer, stru
|
||||
(uint32_t)b->height == e->height
|
||||
: (b->modifier == MOD_LINEAR || b->modifier == MOD_INVALID) &&
|
||||
e->stride == b->stride[0];
|
||||
if (laid_out && e->format == ahb_format_of(b->format, e->modifier) && b->width > 0 && b->height > 0 &&
|
||||
(uint32_t)b->width <= d.width && (uint32_t)b->height <= d.height)
|
||||
const uint32_t expected_format = ahb_format_of(b->format, e->modifier);
|
||||
const int dimensions = b->width > 0 && b->height > 0 &&
|
||||
(uint32_t)b->width <= d.width && (uint32_t)b->height <= d.height;
|
||||
if (laid_out && e->format == expected_format && dimensions) {
|
||||
ahb_swapchain_adopt(c, buffer, b, e->ahb, e->modifier);
|
||||
} else if (mismatch_should_log(b, 2)) {
|
||||
droiddeck_log("layer", "display buffers: gralloc DMA-BUF identity matched but layout was rejected for %s: %c%c%c%c %dx%d stride %u offset %u modifier 0x%llx; gralloc %ux%u stride %u format 0x%x, expected format 0x%x (layout %s, dimensions %s)",
|
||||
droiddeck_client_name(c), b->format & 0xff, (b->format >> 8) & 0xff,
|
||||
(b->format >> 16) & 0xff, (b->format >> 24) & 0xff, b->width, b->height,
|
||||
b->stride[0], b->offset[0], (unsigned long long)b->modifier,
|
||||
e->width, e->height, e->stride, e->format, expected_format,
|
||||
laid_out ? "ok" : "mismatch", dimensions ? "ok" : "mismatch");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (mismatch_should_log(b, 1)) {
|
||||
droiddeck_log("layer", "display buffers: no registered gralloc allocation matches %s's DMA-BUF identity: %c%c%c%c %dx%d stride %u offset %u modifier 0x%llx; imported normally, copy path only",
|
||||
droiddeck_client_name(c), b->format & 0xff, (b->format >> 8) & 0xff,
|
||||
(b->format >> 16) & 0xff, (b->format >> 24) & 0xff, b->width, b->height,
|
||||
b->stride[0], b->offset[0], (unsigned long long)b->modifier);
|
||||
}
|
||||
}
|
||||
|
||||
void display_buffers_init(struct wl_display *display) {
|
||||
|
||||
@@ -86,7 +86,8 @@ RTD=$APP/.wayland-rt
|
||||
export VK_ICD_FILENAMES=$PACK/adapter/icd.json ADRENOTOOLS_DRIVER_PATH=$DRVDIR/ ADRENOTOOLS_HOOKS_PATH=$PACK/lib
|
||||
export ADRENOTOOLS_DRIVER_NAME=$(drvlib "$DRVDIR")
|
||||
export VK_ADD_IMPLICIT_LAYER_PATH=$PACK/layer ENABLE_GAMESCOPE_WSI=1 GAMESCOPE_WAYLAND_DISPLAY=${GAMESCOPE_WAYLAND_DISPLAY:-gamescope-0}
|
||||
export XDG_RUNTIME_DIR=$RTD DROIDDECK_WSI_BYPASS_CHECK_MS=100 GAMESCOPE_WSI_FORCE_BYPASS=1
|
||||
export XDG_RUNTIME_DIR=$RTD DROIDDECK_WSI_BYPASS_CHECK_MS=100 GAMESCOPE_WSI_FORCE_BYPASS=0
|
||||
echo "WSI forced XWayland bypass disabled (GAMESCOPE_WSI_FORCE_BYPASS=$GAMESCOPE_WSI_FORCE_BYPASS)"
|
||||
[ -e "$RTD/droiddeck-gamescope-limiter" ] && export GAMESCOPE_LIMITER_FILE=$RTD/droiddeck-gamescope-limiter
|
||||
|
||||
# Wine: DXVK/VKD3D over the builtins, X11 inside gamescope (winewayland would pick DroidDeck's compositor),
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Exports the build metadata Gradle bakes into BuildConfig and prints the label for DROIDDECK_BUILD_LABEL.
|
||||
set -euo pipefail
|
||||
if [[ -n "$(git status --porcelain)" ]]; then
|
||||
tree_state=dirty
|
||||
else
|
||||
tree_state=clean
|
||||
fi
|
||||
echo "DROIDDECK_BUILD_TREE_STATE=$tree_state" >> "$GITHUB_ENV"
|
||||
if [[ -n "${PR_NUMBER:-}" ]]; then
|
||||
label="pr${PR_NUMBER} at ${PR_HEAD_SHA:0:7}"
|
||||
else
|
||||
label="${BUILD_REF} at ${BUILD_SHA:0:7}"
|
||||
fi
|
||||
echo "label=$label" >> "$GITHUB_OUTPUT"
|
||||
echo "DROIDDECK_SOURCE_COMMIT=${PR_HEAD_SHA:-$BUILD_SHA}" >> "$GITHUB_ENV"
|
||||
echo "DROIDDECK_PR_NUMBER=${PR_NUMBER:-0}" >> "$GITHUB_ENV"
|
||||
echo "DROIDDECK_PR_TITLE=${PR_TITLE//$'\n'/ }" >> "$GITHUB_ENV"
|
||||
echo "Build: \`$label\`" >> "$GITHUB_STEP_SUMMARY"
|
||||
@@ -10,18 +10,13 @@ flowchart LR
|
||||
Source[Pin source tree] --> Components[Prepare verified components]
|
||||
Source --> Xbox[Xbox ARM64 backend]
|
||||
Source --> Tests[Python and native tests]
|
||||
Components --> APK[Compile APK]
|
||||
Components --> APK[Compile APK and Android tests]
|
||||
Xbox --> APK
|
||||
APK --> Gate[Compile and test APK gate]
|
||||
Tests --> Gate
|
||||
Gate --> Publish[Main only: signing and publishing]
|
||||
```
|
||||
|
||||
Kotlin unit tests run in the separate `Unit tests` workflow (`unit-tests.yml`), so a
|
||||
PR test build is published as soon as the APK compiles. Build validation folds both
|
||||
workflows into the `Build APK` commit status, and Release APKs requires both for the
|
||||
released commit.
|
||||
|
||||
All workers verify the same source tree. The component artifact records that tree,
|
||||
recipe identities and every output hash; the APK worker verifies the inventory
|
||||
before building. This handoff verifies consistency within the same CI run. It is
|
||||
|
||||
@@ -494,5 +494,15 @@ gamescope returned the buffer to the client on that release, and a client whose
|
||||
fences attached to a dma-buf then drew into it while the display was still scanning it out, which showed as black
|
||||
tiles in compressed buffers. A forwarded client buffer now stays held until `poll(POLLOUT)` on its dma-buf reports
|
||||
that the display has finished with it, on a waiter thread so nothing else blocks. A release that arrives after the
|
||||
buffer was shown again is dropped, so the later release decides. Composite output images keep the 0146 path, and a
|
||||
buffer was shown again is dropped, so the later release decides. A pending wait holds its own reference on the
|
||||
buffer, since that later release can drop the host's reference before the wait ends. Composite output images keep the 0146 path, and a
|
||||
host that waits for the fence itself releases buffers that are already idle, so nothing changes there.
|
||||
|
||||
## 0148 Wayland backend: composite every frame when the host releases buffers before scanout
|
||||
|
||||
With 0147 a forwarded client buffer stays held until the display has finished scanning it out, about one refresh after
|
||||
the host releases it. Steam's web helper cycles three buffers of its own, so forwarding them held the Steam UI at 80 fps
|
||||
on a 120 Hz screen (frames alternately one and two refreshes apart). The first time a forwarded buffer comes back while
|
||||
it is still being scanned out, the backend now composites every frame into its own output images. Those are reused at
|
||||
latch under 0146, and the client's buffers return as soon as the composite has read them: the Steam UI then runs at
|
||||
the full 120 fps. Hosts that release a buffer only after scanout never take this path and keep forwarding.
|
||||
@@ -1,5 +1,5 @@
|
||||
diff --git a/src/Backends/WaylandBackend.cpp b/src/Backends/WaylandBackend.cpp
|
||||
index 12f0f50..a0fedd4 100644
|
||||
index 12f0f50..d9db2e6 100644
|
||||
--- a/src/Backends/WaylandBackend.cpp
|
||||
+++ b/src/Backends/WaylandBackend.cpp
|
||||
@@ -3,24 +3,28 @@
|
||||
@@ -31,7 +31,7 @@ index 12f0f50..a0fedd4 100644
|
||||
#include <libdecor.h>
|
||||
|
||||
#include "wlr_begin.hpp"
|
||||
@@ -485,44 +489,82 @@ namespace gamescope
|
||||
@@ -485,44 +489,86 @@ namespace gamescope
|
||||
|
||||
// One backing plane plus every layer steamcompmgr can hand us.
|
||||
CWaylandPlane m_Planes[k_nMaxLayers + 1];
|
||||
@@ -78,8 +78,12 @@ index 12f0f50..a0fedd4 100644
|
||||
+ , m_nFd{ nFd }
|
||||
+ , m_ulAcquireSerial{ ulAcquireSerial }
|
||||
+ {
|
||||
+ // A later acquire and release can drop the compositor's reference before this wait ends.
|
||||
+ m_pFb->IncRef();
|
||||
+ }
|
||||
+
|
||||
+ ~CWaylandScanoutRelease() { m_pFb->DecRef(); }
|
||||
+
|
||||
+ int GetFD() override { return m_nFd; }
|
||||
+ void OnPollOut() override { Finish(); }
|
||||
+ void OnPollHangUp() override { Finish(); }
|
||||
@@ -115,7 +119,7 @@ index 12f0f50..a0fedd4 100644
|
||||
~CWaylandInputThread();
|
||||
|
||||
bool Init( CWaylandBackend *pBackend );
|
||||
@@ -969,73 +1011,108 @@ namespace gamescope
|
||||
@@ -969,73 +1015,108 @@ namespace gamescope
|
||||
.action = WAYLAND_NULL(),
|
||||
};
|
||||
const zwp_primary_selection_source_v1_listener CWaylandBackend::s_PrimarySelectionSourceListener =
|
||||
@@ -235,7 +239,7 @@ index 12f0f50..a0fedd4 100644
|
||||
, m_pBackend( pBackend )
|
||||
, m_Planes{ this, this, this, this, this, this, this, this, this }
|
||||
{
|
||||
@@ -2349,25 +2426,26 @@ namespace gamescope
|
||||
@@ -2349,25 +2430,26 @@ namespace gamescope
|
||||
pDmaBuf->format,
|
||||
0u );
|
||||
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
diff --git a/src/Backends/WaylandBackend.cpp b/src/Backends/WaylandBackend.cpp
|
||||
index d9db2e6..5c4cd86 100644
|
||||
--- a/src/Backends/WaylandBackend.cpp
|
||||
+++ b/src/Backends/WaylandBackend.cpp
|
||||
@@ -804,24 +804,31 @@ namespace gamescope
|
||||
{
|
||||
auto iter = m_pOutputs.find( pOutput );
|
||||
if ( iter == m_pOutputs.end() )
|
||||
return nullptr;
|
||||
|
||||
return &iter->second;
|
||||
}
|
||||
|
||||
wl_region *GetEmptyRegion() const { return m_pEmptyRegion; }
|
||||
wl_region *GetFullRegion() const { return m_pFullRegion; }
|
||||
CWaylandFb *GetBlackFb() const { return m_BlackFb.get(); }
|
||||
|
||||
+ bool HostReleasesBeforeScanout() const { return m_bHostReleasesBeforeScanout; }
|
||||
+ void OnHostReleasedBeforeScanout()
|
||||
+ {
|
||||
+ if ( !m_bHostReleasesBeforeScanout.exchange( true ) )
|
||||
+ xdg_log.infof( "Host releases buffers before scanout ends: compositing every frame into our own images" );
|
||||
+ }
|
||||
+
|
||||
void OnConnectorDestroyed( CWaylandConnector *pConnector )
|
||||
{
|
||||
m_pFocusConnector.compare_exchange_strong( pConnector, nullptr );
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void Wayland_Registry_Global( wl_registry *pRegistry, uint32_t uName, const char *pInterface, uint32_t uVersion );
|
||||
static const wl_registry_listener s_RegistryListener;
|
||||
|
||||
void Wayland_Modifier( zwp_linux_dmabuf_v1 *pDmabuf, uint32_t uFormat, uint32_t uModifierHi, uint32_t uModifierLo );
|
||||
|
||||
@@ -871,24 +878,25 @@ namespace gamescope
|
||||
|
||||
wl_display *m_pDisplay = nullptr;
|
||||
wl_shm *m_pShm = nullptr;
|
||||
wl_compositor *m_pCompositor = nullptr;
|
||||
wp_single_pixel_buffer_manager_v1 *m_pSinglePixelBufferManager = nullptr;
|
||||
wl_subcompositor *m_pSubcompositor = nullptr;
|
||||
zwp_linux_dmabuf_v1 *m_pLinuxDmabuf = nullptr;
|
||||
xdg_wm_base *m_pXdgWmBase = nullptr;
|
||||
wp_viewporter *m_pViewporter = nullptr;
|
||||
wl_region *m_pEmptyRegion = nullptr;
|
||||
wl_region *m_pFullRegion = nullptr;
|
||||
Rc<CWaylandFb> m_BlackFb;
|
||||
+ std::atomic<bool> m_bHostReleasesBeforeScanout = { false };
|
||||
OwningRc<CWaylandFb> m_pOwnedBlackFb;
|
||||
OwningRc<CVulkanTexture> m_pBlackTexture;
|
||||
wp_presentation *m_pPresentation = nullptr;
|
||||
droiddeck_refresh_v1 *m_pHostRefresh = nullptr;
|
||||
std::array<uint32_t, 16> m_HostRefreshRates{};
|
||||
std::atomic<uint32_t> m_uHostRefreshRateCount = { 0 };
|
||||
std::vector<uint32_t> m_PendingHostRefreshRates;
|
||||
int m_nSentHostRefresh = 0;
|
||||
int m_nSentHostFrameRate = 0;
|
||||
frog_color_management_factory_v1 *m_pFrogColorMgmtFactory = nullptr;
|
||||
wp_color_manager_v1 *m_pWPColorManager = nullptr;
|
||||
wp_image_description_v1 *m_pWPImageDescriptions[ GamescopeAppTextureColorspace_Count ]{};
|
||||
@@ -1083,24 +1091,25 @@ namespace gamescope
|
||||
xdg_log.errorf( "Compositor released us but we were not acquired. Oh no." );
|
||||
}
|
||||
|
||||
void CWaylandFb::Wayland_Buffer_Release( wl_buffer *pBuffer )
|
||||
{
|
||||
assert( m_pHostBuffer );
|
||||
assert( m_pHostBuffer == pBuffer );
|
||||
|
||||
xdg_log.debugf( "buffer_release: %p", pBuffer );
|
||||
|
||||
if ( ShowsClientBuffer() && gamescope::DmabufScanoutPending( m_nDmabufFd ) )
|
||||
{
|
||||
+ m_pBackend->OnHostReleasedBeforeScanout();
|
||||
int nFd = fcntl( m_nDmabufFd, F_DUPFD_CLOEXEC, 0 );
|
||||
if ( nFd >= 0 )
|
||||
{
|
||||
uint64_t ulSerial;
|
||||
{
|
||||
std::scoped_lock lock( m_AcquireMutex );
|
||||
ulSerial = m_ulAcquireSerial;
|
||||
}
|
||||
auto *pWait = new CWaylandScanoutRelease( this, nFd, ulSerial );
|
||||
if ( CWaylandScanoutRelease::Waiter().AddWaitable( pWait, EPOLLOUT | EPOLLHUP | EPOLLONESHOT ) )
|
||||
return;
|
||||
delete pWait;
|
||||
@@ -1194,24 +1203,27 @@ namespace gamescope
|
||||
plane.Present( nullptr );
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: Dedupe some of this composite check code between us and drm.cpp
|
||||
bool bLayer0ScreenSize = close_enough(pFrameInfo->layers.get( 0 ).scale.x, 1.0f) && close_enough(pFrameInfo->layers.get( 0 ).scale.y, 1.0f);
|
||||
|
||||
GamescopeUpscaleFilter eLayer0Filter = pFrameInfo->layers.get( 0 ).filter;
|
||||
bool bNeedsCompositeFromFilter = ( eLayer0Filter == GamescopeUpscaleFilter::NEAREST ||
|
||||
eLayer0Filter == GamescopeUpscaleFilter::PIXEL ) && !bLayer0ScreenSize;
|
||||
|
||||
bNeedsFullComposite |= cv_composite_force;
|
||||
+ // A forwarded buffer would stay out of its client's hands until scanout ends, which caps a
|
||||
+ // three-image client at two thirds of the refresh rate. Our own output images are reused at latch.
|
||||
+ bNeedsFullComposite |= m_pBackend->HostReleasesBeforeScanout();
|
||||
bNeedsFullComposite |= cv_wayland_overlay_planes >= 0 && pFrameInfo->layers.count() > 1 + cv_wayland_overlay_planes;
|
||||
bNeedsFullComposite |= pFrameInfo->useFSRLayer0;
|
||||
bNeedsFullComposite |= pFrameInfo->useNISLayer0;
|
||||
bNeedsFullComposite |= pFrameInfo->useSGSRLayer0;
|
||||
bNeedsFullComposite |= pFrameInfo->blurLayer0;
|
||||
bNeedsFullComposite |= bNeedsCompositeFromFilter;
|
||||
bNeedsFullComposite |= g_bColorSliderInUse;
|
||||
bNeedsFullComposite |= pFrameInfo->bFadingOut;
|
||||
bNeedsFullComposite |= !g_reshade_effect.empty();
|
||||
|
||||
if ( g_bOutputHDREnabled )
|
||||
bNeedsFullComposite |= g_bHDRItmEnable;
|
||||
@@ -1,3 +1,3 @@
|
||||
GAMESCOPE_REPO=Droid-Deck/DroidDeck-Components
|
||||
GAMESCOPE_TAG=gamescope-3.16.29-cb9c4861
|
||||
GAMESCOPE_SHA256=89a3d70124a13bb5de0b4c67ff75d748a5d7ba6f29590194621754e3550b1f31
|
||||
GAMESCOPE_TAG=gamescope-3.16.29-17928792
|
||||
GAMESCOPE_SHA256=b25680d5f81c8ba1f3e0f6f49894686a148baa296647c3bf3dafa3a04697b7c8
|
||||
@@ -7,21 +7,37 @@ MARK="<!-- droiddeck-pr-build -->"
|
||||
echo
|
||||
[ -f /tmp/pr-merge.md ] && cat /tmp/pr-merge.md
|
||||
echo
|
||||
case "$BUILD_OUTCOME:$APK_OUTCOME" in
|
||||
success:success)
|
||||
case "$BUILD_OUTCOME:$UNIT_TEST_OUTCOME:$APK_OUTCOME" in
|
||||
success:success:success)
|
||||
echo "### Build passed"
|
||||
echo
|
||||
echo "The \`droiddeck-apk\` artifact is [on this run]($RUN_URL), signed with the public test key. Unit tests run in the separate **Unit tests** workflow and must pass before merging."
|
||||
echo "The \`droiddeck-apk\` artifact is [on this run]($RUN_URL), signed with the public test key."
|
||||
echo
|
||||
echo "Same-repository PRs and PRs opened by contributors listed in \`.github/trusted-test-builds.txt\` are eligible for automatic release-signed test builds once the APK compiles. Label the PR \`no-test-build\` to skip that."
|
||||
echo "Same-repository PRs and PRs opened by contributors listed in \`.github/trusted-test-builds.txt\` are eligible for automatic release-signed test builds after the full build passes. Label the PR \`no-test-build\` to skip that."
|
||||
echo "For other PRs, a maintainer can add the \`publish-test\` label to request a signed build."
|
||||
echo
|
||||
echo "Fallback: [open **PR Release Publish**]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/workflows/pr-release-publish.yml) on \`main\` and enter PR \`$PR\`."
|
||||
;;
|
||||
success:*)
|
||||
success:success:*)
|
||||
echo "### APK publication incomplete"
|
||||
echo
|
||||
echo "Compilation passed, but APK publication did not complete. See [the run]($RUN_URL)."
|
||||
echo "Compilation and unit tests passed, but APK publication did not complete. See [the run]($RUN_URL)."
|
||||
;;
|
||||
success:failure:*)
|
||||
echo "### ERROR: Unit tests failed"
|
||||
echo
|
||||
echo "The APK compiled, but unit tests failed. No installable artifact was published."
|
||||
echo
|
||||
if [ -n "$TEST_DIAGNOSTICS_URL" ]; then
|
||||
echo "The [unit-test-results]($TEST_DIAGNOSTICS_URL) artifact contains the test log and any generated reports."
|
||||
else
|
||||
echo "The test diagnostics upload did not complete. See [the test log]($RUN_URL)."
|
||||
fi
|
||||
;;
|
||||
success:*)
|
||||
echo "### Build incomplete"
|
||||
echo
|
||||
echo "The APK compiled, but unit tests did not complete successfully. See [the run]($RUN_URL)."
|
||||
;;
|
||||
failure:*)
|
||||
echo "### ERROR: Build failed"
|
||||
|
||||
@@ -40,31 +40,6 @@ def compilation_state(run, jobs):
|
||||
return "failure" if run["status"] == "completed" else "pending"
|
||||
|
||||
|
||||
def run_state(run):
|
||||
if run["status"] != "completed":
|
||||
return "pending"
|
||||
return "success" if run["conclusion"] == "success" else "failure"
|
||||
|
||||
|
||||
def latest_run(repo, workflow, sha, source_event):
|
||||
query = urlencode({"head_sha": sha, "event": source_event, "per_page": 20})
|
||||
runs = api(f"repos/{repo}/actions/workflows/{workflow}/runs?{query}")["workflow_runs"]
|
||||
runs = [item for item in runs if item["head_sha"] == sha]
|
||||
return max(runs, key=lambda item: item["id"]) if runs else None
|
||||
|
||||
|
||||
def combined_state(build, tests):
|
||||
if build == "failure":
|
||||
return "failure", "APK compilation failed"
|
||||
if tests == "failure":
|
||||
return "failure", "Unit tests failed"
|
||||
if build == "pending":
|
||||
return "pending", "Source validated; awaiting APK compilation"
|
||||
if tests == "pending":
|
||||
return "pending", "APK compiled; awaiting unit tests"
|
||||
return "success", "Source validation, APK compilation and unit tests passed"
|
||||
|
||||
|
||||
def fetch_source(ref, sha):
|
||||
subprocess.run(["git", "fetch", "--no-tags", "origin", ref], check=True)
|
||||
fetched = subprocess.check_output(["git", "rev-parse", "FETCH_HEAD"], text=True).strip()
|
||||
@@ -148,18 +123,19 @@ def main():
|
||||
state = "success"
|
||||
description = "Source validated; no APK source changes"
|
||||
return
|
||||
build_state = tests_state = "pending"
|
||||
latest = latest_run(repo, "build.yml", sha, source_event)
|
||||
if latest:
|
||||
query = urlencode({"head_sha": sha, "event": source_event, "per_page": 20})
|
||||
runs = api(f"repos/{repo}/actions/workflows/build.yml/runs?{query}")["workflow_runs"]
|
||||
runs = [item for item in runs if item["head_sha"] == sha]
|
||||
if runs:
|
||||
latest = max(runs, key=lambda item: item["id"])
|
||||
jobs = api(f"repos/{repo}/actions/runs/{latest['id']}/jobs?per_page=100")["jobs"]
|
||||
build_state = compilation_state(latest, jobs)
|
||||
state = compilation_state(latest, jobs)
|
||||
target = latest["html_url"]
|
||||
tests = latest_run(repo, "unit-tests.yml", sha, source_event)
|
||||
if tests:
|
||||
tests_state = run_state(tests)
|
||||
if tests_state == "failure" and build_state != "failure":
|
||||
target = tests["html_url"]
|
||||
state, description = combined_state(build_state, tests_state)
|
||||
else:
|
||||
state = "pending"
|
||||
description = {"pending": "Source validated; awaiting APK compilation",
|
||||
"success": "Source validation and APK compilation passed",
|
||||
"failure": "APK compilation failed"}[state]
|
||||
finally:
|
||||
api(f"repos/{repo}/statuses/{sha}", "--method", "POST",
|
||||
"-f", "context=Build APK", "-f", f"state={state}",
|
||||
|
||||
@@ -25,7 +25,7 @@ class CiChecksTest(unittest.TestCase):
|
||||
self.assertIn("gitValue(['show', '-s', '--format=%ct', '--end-of-options', sourceCommit])", gradle)
|
||||
|
||||
def test_robolectric_cache_saves_and_restores_the_same_absolute_path(self):
|
||||
steps = yaml.safe_load((ROOT / '.github/workflows/unit-tests.yml').read_text())['jobs']['unit-tests']['steps']
|
||||
steps = yaml.safe_load((ROOT / '.github/workflows/build.yml').read_text())['jobs']['build']['steps']
|
||||
caches = [step['with'] for step in steps if step.get('uses', '').startswith('actions/cache')]
|
||||
for cache in caches:
|
||||
for path in cache['path'].split('\n'):
|
||||
@@ -34,7 +34,7 @@ class CiChecksTest(unittest.TestCase):
|
||||
self.assertEqual(robolectric, ['${{ steps.robolectric-jars.outputs.path }}'] * 2)
|
||||
|
||||
def test_unit_test_retry_requires_maven_exception(self):
|
||||
steps = yaml.safe_load((ROOT / '.github/workflows/unit-tests.yml').read_text())['jobs']['unit-tests']['steps']
|
||||
steps = yaml.safe_load((ROOT / '.github/workflows/build.yml').read_text())['jobs']['build']['steps']
|
||||
run = next(step['run'] for step in steps if step.get('id') == 'unit-tests')
|
||||
line = next(line for line in run.splitlines() if 'grep -Eq' in line)
|
||||
pattern = shlex.split(line)[shlex.split(line).index('-Eq') + 1]
|
||||
@@ -59,31 +59,15 @@ class CiChecksTest(unittest.TestCase):
|
||||
self.assertEqual(result.strip(), '2')
|
||||
|
||||
def test_build_and_tests_use_identical_generated_metadata(self):
|
||||
build = {step.get('id'): step for step in
|
||||
yaml.safe_load((ROOT / '.github/workflows/build.yml').read_text())['jobs']['build']['steps']}
|
||||
tests = {step.get('id'): step for step in
|
||||
yaml.safe_load((ROOT / '.github/workflows/unit-tests.yml').read_text())['jobs']['unit-tests']['steps']}
|
||||
self.assertEqual(build['build']['env'], tests['unit-tests']['env'])
|
||||
self.assertIn('DROIDDECK_BUILD_LABEL', tests['unit-tests']['env'])
|
||||
self.assertIn('SGDB_API_KEY', tests['unit-tests']['env'])
|
||||
self.assertEqual(build['build-label'], tests['build-label'])
|
||||
jobs = yaml.safe_load((ROOT / '.github/workflows/build.yml').read_text())['jobs']
|
||||
steps = {step.get('id'): step for step in jobs['build']['steps']}
|
||||
self.assertEqual(steps['build']['env'], steps['unit-tests']['env'])
|
||||
self.assertIn('DROIDDECK_BUILD_LABEL', steps['unit-tests']['env'])
|
||||
self.assertIn('SGDB_API_KEY', steps['unit-tests']['env'])
|
||||
gradle = (ROOT / 'app/build.gradle').read_text()
|
||||
self.assertIn("outputs.doNotCacheIf('CI executes the test suite on every run') { true }", gradle)
|
||||
self.assertIn('outputs.upToDateWhen { false }', gradle)
|
||||
|
||||
def test_unit_tests_do_not_hold_up_the_apk(self):
|
||||
build = yaml.safe_load((ROOT / '.github/workflows/build.yml').read_text())
|
||||
for step in build['jobs']['build']['steps']:
|
||||
self.assertNotIn('UnitTest', step.get('run', ''))
|
||||
tests = yaml.safe_load((ROOT / '.github/workflows/unit-tests.yml').read_text())
|
||||
for event in ('push', 'pull_request'):
|
||||
self.assertEqual(tests[True][event], build[True][event])
|
||||
authorship = yaml.safe_load((ROOT / '.github/workflows/authorship.yml').read_text())
|
||||
self.assertEqual(set(authorship[True]['workflow_run']['workflows']), {build['name'], tests['name']})
|
||||
self.assertIn('unit-tests.yml', (ROOT / '.github/workflows/release.yml').read_text())
|
||||
run = next(step['run'] for step in tests['jobs']['unit-tests']['steps'] if step.get('id') == 'unit-tests')
|
||||
self.assertIn('-PunitTestsOnly=true', run)
|
||||
|
||||
def test_independent_jobs_wait_only_for_the_pinned_source(self):
|
||||
jobs = yaml.safe_load((ROOT / '.github/workflows/build.yml').read_text())['jobs']
|
||||
for name in ('xbox', 'python-tests', 'components-runner'):
|
||||
|
||||
@@ -136,10 +136,21 @@ int main( int argc, char **argv ) {
|
||||
assert( fb.refs == 2 );
|
||||
d.scanning();
|
||||
fb.Wayland_Buffer_Release( fb.m_pHostBuffer );
|
||||
assert( fb.refs == 2 && fb.m_bCompositorAcquired );
|
||||
assert( fb.refs == 3 && fb.m_bCompositorAcquired );
|
||||
d.done();
|
||||
fire();
|
||||
assert( fb.refs == 1 && !fb.m_bCompositorAcquired && xdg_log.oh_no == 0 );
|
||||
} else if ( which == "stale-wait-keeps-buffer" ) {
|
||||
fb.client = true;
|
||||
fb.OnCompositorAcquire();
|
||||
d.scanning();
|
||||
fb.Wayland_Buffer_Release( fb.m_pHostBuffer );
|
||||
fb.OnCompositorAcquire();
|
||||
d.done();
|
||||
fb.Wayland_Buffer_Release( fb.m_pHostBuffer );
|
||||
assert( fb.refs == 2 && !fb.m_bCompositorAcquired );
|
||||
fire();
|
||||
assert( fb.refs == 1 && xdg_log.oh_no == 0 );
|
||||
} else if ( which == "client-idle" ) {
|
||||
fb.client = true;
|
||||
fb.OnCompositorAcquire();
|
||||
@@ -214,6 +225,9 @@ class ForwardedBufferScanoutTest(unittest.TestCase):
|
||||
def test_buffer_shown_again_waits_for_its_next_release(self):
|
||||
self.scenario("shown-again")
|
||||
|
||||
def test_pending_wait_keeps_the_buffer_after_a_later_release(self):
|
||||
self.scenario("stale-wait-keeps-buffer")
|
||||
|
||||
def test_buffer_without_dmabuf_is_released_at_once(self):
|
||||
self.scenario("no-dmabuf")
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class ValidateApkTest(unittest.TestCase):
|
||||
def git(self, *args):
|
||||
return subprocess.check_output(["git", "-C", self.root, *args], text=True).strip()
|
||||
|
||||
def validate(self, message="Source change", body="", result="success", stale=False, completed=False, filename="source.kt", permission="write", role_name="write", fork=False, tests="success"):
|
||||
def validate(self, message="Source change", body="", result="success", stale=False, completed=False, filename="source.kt", permission="write", role_name="write", fork=False):
|
||||
(self.root / filename).parent.mkdir(parents=True, exist_ok=True)
|
||||
(self.root / filename).write_text(message)
|
||||
self.git("add", filename)
|
||||
@@ -57,12 +57,6 @@ class ValidateApkTest(unittest.TestCase):
|
||||
return [pr]
|
||||
if "workflows/build.yml/runs?" in path:
|
||||
return {"workflow_runs": [{"id": 7, "head_sha": sha, "status": "completed", "html_url": "https://example.org/build"}]}
|
||||
if "workflows/unit-tests.yml/runs?" in path:
|
||||
if tests is None:
|
||||
return {"workflow_runs": []}
|
||||
return {"workflow_runs": [{"id": 9, "head_sha": sha, "html_url": "https://example.org/tests",
|
||||
"status": "in_progress" if tests == "pending" else "completed",
|
||||
"conclusion": None if tests == "pending" else tests}]}
|
||||
if path.endswith("/jobs?per_page=100"):
|
||||
return {"jobs": [{"name": "Compile and test APK", "status": "in_progress" if result == "pending" else "completed", "conclusion": result}]}
|
||||
raise AssertionError(path)
|
||||
@@ -91,18 +85,6 @@ class ValidateApkTest(unittest.TestCase):
|
||||
self.validate(result=result)
|
||||
self.assertEqual(self.statuses[-1]["state"], result)
|
||||
|
||||
def test_unit_tests_must_pass_too(self):
|
||||
for tests, state in (("pending", "pending"), (None, "pending"), ("failure", "failure"), ("cancelled", "failure")):
|
||||
with self.subTest(tests=tests):
|
||||
self.validate(tests=tests)
|
||||
self.assertEqual(self.statuses[-1]["state"], state)
|
||||
self.assertEqual(self.statuses[-1]["target_url"], "https://example.org/tests")
|
||||
|
||||
def test_a_compile_failure_is_reported_before_test_results(self):
|
||||
self.validate(result="failure", tests="failure")
|
||||
self.assertEqual(self.statuses[-1]["description"], "APK compilation failed")
|
||||
self.assertEqual(self.statuses[-1]["target_url"], "https://example.org/build")
|
||||
|
||||
def test_superseded_event_cannot_replace_current_status(self):
|
||||
self.validate(stale=True)
|
||||
self.assertEqual(self.statuses, [])
|
||||
|
||||
@@ -15,6 +15,8 @@ SRC = TESTS.parents[1] / "app/src/main/cpp/waylandcomp/src"
|
||||
LAYER_HARNESS = r'''
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <vulkan/vulkan.h>
|
||||
#include "vk_external_image_sync.h"
|
||||
#include "vk_linear_dmabuf.h"
|
||||
@@ -42,6 +44,11 @@ static const uint32_t g_qfam = 2;
|
||||
%(width)s
|
||||
%(height)s
|
||||
static int black_fill_below(const struct draw_list *dl, int n) { (void)dl; (void)n; return 0; }
|
||||
#define LAYER_CANDIDATE_DIAGNOSTICS 32u
|
||||
static unsigned g_layer_candidate_diag_count;
|
||||
static int g_layer_candidate_diag_limit;
|
||||
static void droiddeck_log(const char *tag, const char *fmt, ...) { (void)tag; (void)fmt; }
|
||||
%(candidate_skip)s
|
||||
%(candidate)s
|
||||
|
||||
static int candidate(struct vkp_image *img) {
|
||||
@@ -135,6 +142,7 @@ class VkLinearDmabufTest(unittest.TestCase):
|
||||
"is_dmabuf": function(vk, "vkp_image_is_dmabuf"),
|
||||
"width": function(vk, "vkp_image_width"),
|
||||
"height": function(vk, "vkp_image_height"),
|
||||
"candidate_skip": function(comp, "note_layer_candidate_skip"),
|
||||
"candidate": function(comp, "layer_candidate"),
|
||||
}
|
||||
with tempfile.TemporaryDirectory(prefix="droiddeck-vk-linear-layer-") as tmp:
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
from test_vk_pending_completion import function
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
SRC = ROOT / 'app/src/main/cpp/waylandcomp/src'
|
||||
|
||||
HARNESS = r'''
|
||||
#define _GNU_SOURCE
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <poll.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <wayland-util.h>
|
||||
struct wl_listener { struct wl_list link; void (*notify)(struct wl_listener *, void *); };
|
||||
struct wl_event_source;
|
||||
struct wl_client;
|
||||
struct wl_resource;
|
||||
struct surface { int unused; };
|
||||
struct vkp_draw { int unused; };
|
||||
struct dmabuf_buffer { int fd; void *slot; };
|
||||
typedef struct AHardwareBuffer { int unused; } AHardwareBuffer;
|
||||
DEFINES
|
||||
STRUCT
|
||||
static unsigned g_stat_zero_copy;
|
||||
static int g_export_failed_logged;
|
||||
static struct surface *g_announced;
|
||||
static volatile int64_t g_last_zero_copy_ns;
|
||||
static int export_ok, exports, presents, presented_acquire, logs, polls;
|
||||
static int fake_ioctl(int fd, unsigned long req, void *arg) {
|
||||
struct droiddeck_dma_buf_sync_file *f = arg;
|
||||
(void)fd;
|
||||
assert(req == DROIDDECK_DMA_BUF_IOCTL_EXPORT_SYNC_FILE && f->flags == DROIDDECK_DMA_BUF_SYNC_READ);
|
||||
++exports;
|
||||
if (!export_ok) { errno = ENOTTY; return -1; }
|
||||
f->fd = dup(0);
|
||||
return 0;
|
||||
}
|
||||
#define ioctl fake_ioctl
|
||||
static int fake_poll(struct pollfd *p, nfds_t n, int timeout) {
|
||||
assert(n == 1 && p->events == POLLIN && timeout == 100);
|
||||
++polls; p->revents = POLLIN; return 1;
|
||||
}
|
||||
#define poll fake_poll
|
||||
static int64_t now_ns(void) { return 1; }
|
||||
static void **droiddeck_dmabuf_ahb_slot(struct dmabuf_buffer *b) { return &b->slot; }
|
||||
static int droiddeck_dmabuf_fd(struct dmabuf_buffer *b) { return b->fd; }
|
||||
static const void *droiddeck_surface_color(struct surface *s) { (void)s; return NULL; }
|
||||
static void droiddeck_surface_describe(struct surface *s, char *out, size_t n) { (void)s; snprintf(out, n, "game"); }
|
||||
static void droiddeck_log(const char *tag, const char *fmt, ...) { (void)tag; (void)fmt; ++logs; }
|
||||
static int sc_layer_present_ahb(AHardwareBuffer *a, int w, int h, int acquire, void *token, int sw, int sh,
|
||||
const struct vkp_draw *d, const void *color, uint32_t format) {
|
||||
(void)a; (void)w; (void)h; (void)token; (void)sw; (void)sh; (void)d; (void)color; (void)format;
|
||||
++presents; presented_acquire = acquire;
|
||||
if (acquire >= 0) close(acquire);
|
||||
return 0;
|
||||
}
|
||||
FUNCTIONS
|
||||
static void run(int fd, int can_export, int copyable) {
|
||||
struct dmabuf_buffer b = {.fd = fd};
|
||||
struct vkp_draw d;
|
||||
const struct vkp_draw *draw = copyable ? &d : NULL;
|
||||
struct ahb_buf ab;
|
||||
struct surface s;
|
||||
memset(&ab, 0, sizeof(ab));
|
||||
ab.id = 7; ab.w = 64; ab.h = 64; ab.fence_fd = -1;
|
||||
b.slot = &ab;
|
||||
export_ok = can_export;
|
||||
int r = ahb_swapchain_present(&b, &s, 64, 64, draw);
|
||||
if (fd >= 0 && can_export) {
|
||||
assert(r == 0 && presents == 1 && presented_acquire >= 0 && ab.on_layer && g_stat_zero_copy == 1 && polls == 0);
|
||||
} else if (copyable) {
|
||||
assert(r == -1 && presents == 0 && !ab.on_layer && g_stat_zero_copy == 0 && polls == (fd >= 0));
|
||||
r = ahb_swapchain_present(&b, &s, 64, 64, draw);
|
||||
assert(r == -1 && presents == 0 && logs == 1);
|
||||
} else {
|
||||
assert(r == 0 && presents == 1 && presented_acquire == -1 && ab.on_layer && polls == (fd >= 0));
|
||||
}
|
||||
}
|
||||
int main(int argc, char **argv) {
|
||||
assert(argc == 4);
|
||||
run(atoi(argv[1]), atoi(argv[2]), atoi(argv[3]));
|
||||
return 0;
|
||||
}
|
||||
'''
|
||||
|
||||
|
||||
class ZeroCopyAcquireFenceTest(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cc = shutil.which(os.environ.get('CC', 'cc'))
|
||||
if not cc:
|
||||
raise AssertionError('C compiler required')
|
||||
ahb = (SRC / 'ahb_swapchain.c').read_text()
|
||||
defines = '\n'.join(re.findall(r'^(?:struct droiddeck_dma_buf_sync_file \{.*?\};|#define DROIDDECK_DMA_BUF_\w+ .*)$',
|
||||
ahb, re.M))
|
||||
struct = re.search(r'struct ahb_buf \{.*?\n\};', ahb, re.S).group()
|
||||
source = HARNESS.replace('DEFINES', defines).replace('STRUCT', struct)
|
||||
source = source.replace('FUNCTIONS', function(ahb, 'ahb_swapchain_present'))
|
||||
cls.tmp = tempfile.TemporaryDirectory(prefix='droiddeck-acquire-fence-')
|
||||
cls.addClassCleanup(cls.tmp.cleanup)
|
||||
probe = Path(cls.tmp.name) / 'probe.c'
|
||||
probe.write_text(source)
|
||||
cls.binary = probe.with_suffix('')
|
||||
built = subprocess.run([cc, '-std=c11', '-Wall', '-Wextra', '-Werror', '-Wno-unused-function', '-UNDEBUG',
|
||||
'-include', 'stdio.h', '-I', str(SRC.parent / 'prebuilt/include'), str(probe),
|
||||
'-o', str(cls.binary)],
|
||||
capture_output=True, text=True)
|
||||
if built.returncode:
|
||||
raise AssertionError(built.stdout + built.stderr)
|
||||
|
||||
def scenario(self, fd, can_export, copyable=1):
|
||||
result = subprocess.run([str(self.binary), str(fd), str(can_export), str(copyable)], capture_output=True, text=True,
|
||||
timeout=10)
|
||||
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
||||
|
||||
def test_exported_fence_goes_to_the_display(self):
|
||||
self.scenario(5, 1)
|
||||
|
||||
def test_kernel_without_fence_export_falls_back_to_copy(self):
|
||||
self.scenario(5, 0)
|
||||
|
||||
def test_buffer_without_dmabuf_fd_falls_back_to_copy(self):
|
||||
self.scenario(-1, 1)
|
||||
|
||||
def test_uncopyable_buffer_waits_on_the_cpu_and_stays_on_the_layer(self):
|
||||
self.scenario(5, 0, 0)
|
||||
|
||||
def test_uncopyable_buffer_without_dmabuf_fd_stays_on_the_layer(self):
|
||||
self.scenario(-1, 1, 0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user